withHeader('Access-Control-Allow-Origin', '*') ->withHeader('Access-Control-Allow-Credentials', 'true') // Headers 可以根据实际情况进行改写。 ->withHeader('Access-Control-Allow-Headers', '*'); Context::set(ResponseInterface::class, $response); if ($request->getMethod() == 'OPTIONS') { return $response; } // var_dump($request); return $handler->handle($request); } }