56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
|
|
// +----------------------------------------------------------------------
|
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
|
// +----------------------------------------------------------------------
|
|
// | Author: liu21st <liu21st@gmail.com>
|
|
// +----------------------------------------------------------------------
|
|
// [ 应用入口文件 ]
|
|
|
|
//------------------------解决跨域问题-------------------------------------
|
|
// 允许的域名列表
|
|
$allowedOrigins = [
|
|
"http://adminht.qxmier.com", // Vue 开发环境
|
|
"http://chat.qxmier.com",
|
|
];
|
|
|
|
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
|
|
|
// 检查来源是否在允许列表中
|
|
// if (in_array($origin, $allowedOrigins)) {
|
|
|
|
// } else {
|
|
// // 生产环境可以返回错误
|
|
// header("HTTP/1.1 403 Forbidden");
|
|
// exit();
|
|
// }
|
|
header("Access-Control-Allow-Origin: $origin");
|
|
// 统一设置其他 CORS 头
|
|
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
|
|
header("Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With");
|
|
header("Access-Control-Allow-Credentials: true");
|
|
header("Access-Control-Max-Age: 86400"); // 预检缓存时间
|
|
|
|
// 直接响应 OPTIONS 请求
|
|
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
|
http_response_code(200);
|
|
exit();
|
|
}
|
|
//------------------------解决跨域问题-------------------------------------
|
|
|
|
// 定义应用目录
|
|
define('APP_PATH', __DIR__ . '/../application/');
|
|
|
|
// 判断是否安装
|
|
if (!is_file(APP_PATH . 'admin/command/Install/install.lock')) {
|
|
header("location:./install.php");
|
|
exit;
|
|
}
|
|
|
|
// 加载框架引导文件
|
|
require __DIR__ . '/../thinkphp/start.php';
|