From bec8e82d3095ce77991a5dffcd20bba1bfb17909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 16 Dec 2020 16:22:17 +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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/HttpServer/Events/OnRequest.php b/HttpServer/Events/OnRequest.php index 86173c13..536ee22d 100644 --- a/HttpServer/Events/OnRequest.php +++ b/HttpServer/Events/OnRequest.php @@ -55,6 +55,11 @@ class OnRequest extends Callback try { /** @var HRequest $sRequest */ [$sRequest, $sResponse] = [HRequest::create($request), HResponse::create($response)]; + + $sResponse->addHeader('Access-Control-Allow-Origin', '*'); + $sResponse->addHeader('Access-Control-Allow-Headers', $sRequest->get('access-control-request-headers')); + $sResponse->addHeader('Access-Control-Request-Method', $sRequest->get('access-control-request-method')); + if ($sRequest->is('favicon.ico')) { return $sResponse->send($sRequest->isNotFound(), 200); }