From ff80ab71e6bcd090cba668f4af3d6ee3d6cc735a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=96=E5=8F=AB?= <392494244@qq.com> Date: Fri, 8 Dec 2023 14:53:45 +0800 Subject: [PATCH] 1 --- public/index.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/public/index.php b/public/index.php index 35da5a2..ab6b9d8 100755 --- a/public/index.php +++ b/public/index.php @@ -12,6 +12,18 @@ // [ 应用入口文件 ] namespace think; + +header('Content-Type: text/html;charset=utf-8'); +header('Access-Control-Allow-Origin:*'); // *代表允许任何网址请求 +header('Access-Control-Allow-Methods:POST,GET,OPTIONS,DELETE,PUT'); // 允许请求的类型 +header('Access-Control-Allow-Credentials: true'); // 设置是否允许发送 cookies +header('Access-Control-Allow-Headers: Content-Type,Content-Length,Accept-Encoding,X-Requested-with, Origin,x-csrf,Authorization,x-app-client-id,x-app-platform,x-app-version,x-csrf,x-mch-id,x-requested-time,x-requested-with,Language,access_token'); // 设置允许自定义请求头的字段 +// comment out the following two lines when deployed to production +if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){ + echo json_encode(['code'=>'0','msg'=>'ok']); + exit(); +} + // 检测PHP环境 //if (version_compare(PHP_VERSION, '7.4.0', '<')) die('require PHP > 7.1.0 !'); // 检测php版本号