This commit is contained in:
尖叫 2023-12-08 14:53:45 +08:00
parent 3fab8615cb
commit ff80ab71e6

View File

@ -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版本号