From a272edcca51098a581e991b6034991ea1e21ed65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 16 Dec 2020 16:28:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Events/OnRequest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/HttpServer/Events/OnRequest.php b/HttpServer/Events/OnRequest.php index f2034021..93d179b3 100644 --- a/HttpServer/Events/OnRequest.php +++ b/HttpServer/Events/OnRequest.php @@ -56,6 +56,10 @@ class OnRequest extends Callback /** @var HRequest $sRequest */ [$sRequest, $sResponse] = [HRequest::create($request), HResponse::create($response)]; + $sResponse->addHeader('Access-Control-Allow-Origin', '*'); + $sResponse->addHeader('Access-Control-Allow-Headers', $sRequest->headers->get('access-control-request-headers')); + $sResponse->addHeader('Access-Control-Request-Method', $sRequest->headers->get('access-control-request-method')); + if ($sRequest->is('favicon.ico')) { return $sResponse->send($sRequest->isNotFound(), 200); }