tp6跨域访问最新写法
public function handle($request, Closure $next, ? array $header = []) { $header = !empty($header) ? array_merge($this->header, $header) : $this->header; if (!isset($header['Access-Control-Allow-Origin'])) { $origin = $request->header('origin'); if ($origin && ('' == $this->cookieDomain || strpos($origin, $this->cookieDomain))) { $header['Access-Control-Allow-Origin'] = $origin; } else { $header['Access-Control-Allow-Origin'] = '*'; } } if ($request->method() == 'OPTIONS') { $response = response(''); } else { $response = $next($request); } return $response->header($header); }标签:origin,跨域,header,request,Access,tp6,Allow,写法,response From: https://www.cnblogs.com/newmiracle/p/17262286.html