0
点赞
收藏
分享

微信扫一扫

thinkphp5跨域问题

首先我想到的是在配置文件中加跨域

header("Access-Control-Allow-Origin:*");

header('Access-Control-Allow-Methods:*');

header('Access-Control-Allow-Headers:x-requested-with, content-type,token');

header('Access-Control-Allow-Credentials', 'true');

然而我发现这样做并不生效。

于是尝试在入口文件中加入就可以了,如下

thinkphp5跨域问题_配置文件

注意不要配置文件和入口文件同时加否则也会报错!

举报

相关推荐

0 条评论