feat(api): 添加 CORS headers 支持跨域访问(UniApp 直连)

feat/b-verification-clean
Council 2026-05-14 11:57:38 +08:00
parent 683dee75dc
commit 9617f5c4c0
1 changed files with 4 additions and 0 deletions

View File

@ -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);
?>