Ver código fonte

feat: 支持跨域配置,方便前端开发环境¼š测试

jiangzixin 2 anos atrás
pai
commit
fbaeaab926
1 arquivos alterados com 6 adições e 1 exclusões
  1. 6 1
      public/index.php

+ 6 - 1
public/index.php

@@ -3,6 +3,11 @@
 //ini_set("display_errors",'on');
 //error_reporting(E_ALL);
 
+header("Access-Control-Allow-Origin:*");
+header("Access-Control-Allow-Methods:GET, POST, OPTIONS, DELETE");
+header("Access-Control-Allow-Headers:x-requested-with, Referer,content-type,token,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type, Accept-Language, Origin, Accept-Encoding");
+// 不用多说,就是上面三行,注意第三行,里面有一个参数:token,这个是为后面自定义header头准备的<br>
+
 // 版本信息
 define('PRODUCT_NAME', 'Tplay');
 define('PRODUCT_VERSION', 'v2.1.8');
@@ -14,4 +19,4 @@ define('EXTEND_PATH', __DIR__ . '/../extend/');
 // 重定义第三方类库目录
 define('VENDOR_PATH', __DIR__ . '/../vendor/');
 // 加载框架引导文件
-require __DIR__ . '/../thinkphp/start.php';
+require __DIR__ . '/../thinkphp/start.php';