调试允许跨站请求
Posted mull
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了调试允许跨站请求相关的知识,希望对你有一定的参考价值。
2018-11-12 13:34:12
调试允许跨站请求
A站:http://127.0.0.1:35585
B站:http://192.168.58.228
A站请求:
$.getJson("http://192.168.58.228/api/api.php", function(res){ ... });
B站响应头需加入:
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Referer, User-Agent, Authorization, X-Auth-Token
Access-Control-Allow-Credentials: true
如果B用APACHE,可以在httpd.conf尾加入:
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Referer, User-Agent, Authorization, X-Auth-Token"
Header always set Access-Control-Allow-Credentials "true"
以上是关于调试允许跨站请求的主要内容,如果未能解决你的问题,请参考以下文章
第二百七十一节,Tornado框架-CSRF防止跨站post请求伪造