From 9617f5c4c0e628ddc5255cecda31ffa42fd563a5 Mon Sep 17 00:00:00 2001 From: Council Date: Thu, 14 May 2026 11:57:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=20CORS=20header?= =?UTF-8?q?s=20=E6=94=AF=E6=8C=81=E8=B7=A8=E5=9F=9F=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=EF=BC=88UniApp=20=E7=9B=B4=E8=BF=9E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shopxo/public/api.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shopxo/public/api.php b/shopxo/public/api.php index 9d2277c..74cea29 100644 --- a/shopxo/public/api.php +++ b/shopxo/public/api.php @@ -21,6 +21,10 @@ require __DIR__ . '/../vendor/autoload.php'; // 执行HTTP应用并响应 $http = (new App())->http; $response = $http->name('api')->run(); +header('Access-Control-Allow-Origin: *'); +header('Access-Control-Allow-Methods: GET, POST, OPTIONS'); +header('Access-Control-Allow-Headers: DNT,User-Agent,Cache-Control,Content-Type,ajax,Authorization,token'); +if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; } $response->send(); $http->end($response); ?> \ No newline at end of file