标签:json header res 127.0.0.1 httpd function red use 请求
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"
标签:json header res 127.0.0.1 httpd function red use 请求
原文地址:https://www.cnblogs.com/mull/p/9946553.html