跨域问题解决方案

跨域解决方案:
1、通过JSONP跨域(前端Jquery封装Ajax请求)
2、document.domain + iframe跨域(主域相同,子域不同)
3、location.hash + iframe跨域
4、window.name + iframe跨域
5、postMessage跨域
6、跨域资源共享(CORS)
7、nginx代理跨域
8、node.js中间件代理跨域
9、WebSocket协议跨域


跨资源共享(CORS):
response.setHeader("Access-Control-Allow-Origin","*")
response.setHeader("Access-Control-Allow-Credentials","true");
注意:当"Access-Control-Allow-Credentials"为true时,不能用"*",需要指定具体域名

posted @ 2020-06-04 22:34  河东斗阑干  阅读(99)  评论(0)    收藏  举报