Files
fast_response/front/public/index.php
Your Name dce091da91 t
2025-03-27 07:52:44 +00:00

46 lines
1.8 KiB
PHP
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// [ 应用入口文件 ]
namespace think;
// 加载基础文件
require __DIR__ . '/../thinkphp/base.php';
// 支持事先使用静态方法设置Request对象和Config对象
header('Content-Type: application/json');
// 检查请求方法
//if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
// // 这是一个预检请求
// //echo json_encode(['message' => 'Preflight request received.']);
//
// // 设置CORS响应头部
// header('Access-Control-Allow-Origin: *');
// header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
// header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token');
// header('Access-Control-Max-Age: 86400'); // 缓存一天
//
// // 预检请求不需要返回实际的数据只需要发送200状态码即可
// http_response_code(200);
// exit;
//}
header("Access-Control-Allow-Origin: *");//允许所有地址跨域请求
// CORS
// 告诉浏览器, 允许哪些请求方式
header("Access-Control-Request-Methods:GET, POST");
// 告诉浏览器, 允许哪些额外的请求头信息
header('Access-Control-Allow-Headers:x-requested-with,content-type,test-token,token,test-sessid,authorization');
// 执行应用并响应
Container::get('app')->run()->send();