inpm
! dlrow olleH

跨域

2018-12-29 js
Word count: 100 | Reading time: 1min

同源策略

  • 协议+域名+端口 相同
  • 限制Cookie、localStorage、IndexDB、Ajax

方案

  • 通过jsonp跨域
  • document.domain + iframe跨域
  • location.hash + iframe
  • window.name + iframe跨域
  • postMessage跨域
  • 跨域资源共享(CORS)
  • nginx代理跨域
  • nodejs中间件代理跨域
  • WebSocket协议跨域

总结

  • CORS为主流解决方案
  • 反向代理的配置与使用nodejs中间件原理类似
  • 各方案优缺点

Author: inpm.cy@gmail.com

Link: https://inpm.top/2018/12/29/cors/

Copyright: All articles in this blog are licensed under inpm unless stating additionally.

< PreviousPost
关于团队
NextPost >
博客说明
CATALOG
  1. 1. 同源策略
  2. 2. 方案
  3. 3. 总结