feat:放行所有options请求

This commit is contained in:
妙码生花 2022-08-06 23:30:21 +08:00
parent 4d887bdfd0
commit 43d2879aed

View File

@ -16,10 +16,17 @@ namespace think;
* 不在tp加载后判断为了安全的使用exit()
* 使用绝对路径确保花里胡哨的url均能正确判定和跳转
*/
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
header("Access-Control-Allow-Credentials: true");
header("Access-Control-Max-Age: 86400");
header("Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS");
header("Access-Control-Allow-Headers: " . $_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']);
header("Access-Control-Allow-Origin: *");
exit();
}
$rootPath = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
$server = isset($_REQUEST['server']) || isset($_SERVER['HTTP_SERVER']) || substr($_SERVER['REQUEST_URI'], 1, 9) == 'index.php';
if (!$server) {
// 用户访问前端