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