issues
search
LLwanran
/
front_end_studying
前端知识要点
https://llwanran.github.io/front_end_studying/
2
stars
1
forks
source link
跨域的方式有哪些?(珠海金山WPS电面我的题)
#3
Open
LLwanran
opened
5 years ago
LLwanran
commented
5 years ago
JSONP
CORS
postMessage
Nginx反向代理
Node中间件代理
Websocket
window.name + iframe
location.hash + iframe
document.domain + iframe
CORS 支持所有类型的HTTP请求,是跨域HTTP请求的根本解决方案
JSONP 只支持GET请求,JSONP的优势在于支持老式浏览器,以及可以向不支持CORS的网站请求数据
不管是Node中间件代理还是Nginx反向代理,主要是通过同源策略对服务器不加限制
日常工作中,用得比较多的跨域方案是CORS和Nginx反向代理
CORS 支持所有类型的HTTP请求,是跨域HTTP请求的根本解决方案
JSONP 只支持GET请求,JSONP的优势在于支持老式浏览器,以及可以向不支持CORS的网站请求数据
不管是Node中间件代理还是Nginx反向代理,主要是通过同源策略对服务器不加限制
日常工作中,用得比较多的跨域方案是CORS和Nginx反向代理