Thinkphp开发接口跨域问题

发布时间:2020-08-07 09:46:39 作者:哈尔滨app开发公司哈尔滨app开发app开发公司

访问接口出错:Failed to load http: localhost:8080 XXXX: No & 39;Access-Control-Allow-Origin& 39; header is present on t

访问接口出错:
Failed to load http://localhost:8080/XXXX: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

说明接口输入格式跨域没有设置,在 thinkphp中接口输出或index.php中添加代码 :

header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header('Access-Control-Allow-Methods: GET, POST, PUT');
评论

相关阅读



联系我们

哈尔滨云创科技有限公司

地址:黑龙江省哈尔滨市南岗高新开发区嵩山路5号
电话:0451-51035763 51030378
在线QQ:191814825