码迷,mamicode.com
首页 > 其他好文 > 详细

调试允许跨站请求

时间:2018-11-12 15:49:42      阅读:138      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!