|
|
@@ -14,9 +14,20 @@ date_default_timezone_set('PRC');
|
|
|
// [ 应用入口文件 ]
|
|
|
//编码
|
|
|
header('content-type:text/html;charset=utf-8');
|
|
|
+// 处理预请求报错(将请求的头部数据全部允许,然后直接返回).
|
|
|
+if($_SERVER['REQUEST_METHOD'] == 'OPTIONS'){
|
|
|
+ header("Access-Control-Allow-Origin: *");
|
|
|
+ header("Access-Control-Allow-Credentials", "true");
|
|
|
+ header("Access-Control-Max-Age", "3600");
|
|
|
+ header("Access-Control-Allow-Headers: Origin, X-Requested-With, X-Custom-Header, Content-Type, Accept, Authorization, userToken, apiToken");
|
|
|
+ header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH');
|
|
|
+ header('Access-Control-Expose-Headers', "userToken, apiToken");
|
|
|
+ exit;
|
|
|
+}
|
|
|
//跨域
|
|
|
-header('Access-Control-Allow-Origin: *');
|
|
|
-header("Access-Control-Allow-Credentials: true");
|
|
|
+header('Access-Control-Allow-Origin:*');
|
|
|
+header('Access-Control-Allow-Methods:OPTIONS, GET, POST'); // 允许option,get,post请求
|
|
|
+header('Access-Control-Allow-Headers:x-requested-with'); // 允许x-requested-with请求头
|
|
|
// 定义应用目录
|
|
|
define('APP_PATH', __DIR__ . '/../application/');
|
|
|
// 加载框架引导文件
|