From 461092f1d50a573d8bfa753df7a40bbaf7b45711 Mon Sep 17 00:00:00 2001 From: Ghost <106998207@qq.com> Date: Wed, 2 Apr 2025 16:11:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=B4=E9=83=A8=E6=8F=90=E4=BA=A4=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E8=B7=A8=E5=9F=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/public/index.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Server/public/index.php b/Server/public/index.php index db34ed58..ea854690 100755 --- a/Server/public/index.php +++ b/Server/public/index.php @@ -12,6 +12,17 @@ // [ 应用入口文件 ] namespace think; +//处理跨域预检请求 +if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){ + //允许的源域名 + header("Access-Control-Allow-Origin: *"); + //允许的请求头信息 + header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"); + //允许的请求类型 + header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH'); + exit; +} + define('ROOT_PATH', dirname(__DIR__)); define('DS', DIRECTORY_SEPARATOR);