1.应用场景
主要用于跨域访问. 了解并且使用常见的跨域解决方案. |
2.学习/操作
1.文档阅读 http://www.ruanyifeng.com/blog/2016/04/cors.html //跨域资源共享 CORS 详解 -- 推荐阅读 https://wangdoc.com/javascript/bom/cors.html https://enable-cors.org/server_expressjs.html // CORS on ExpressJS https://github.com/facebook/create-react-app/blob/master/docusaurus/docs/proxying-api-requests-in-development.md // react 跨域解决方案 https://blog.csdn.net/william_n/article/details/108123718 // 浏览器何时发送一个OPTIONS请求? CORS[跨域资源共享] - 学习/实践 https://yunp.top/blog/index.php/2016/05/12/44/ // 跨域访问 2.整理输出 实践code: https://github.com/ningxiaofa/react-fetch-learning react 中使用fetch请求, 解决跨域访问: 方式一: react跨域解决方案: https://github.com/facebook/create-react-app/blob/master/docusaurus/docs/proxying-api-requests-in-development.md 更多问题参见: https://github.com/chimurai/http-proxy-middleware/tree/v0.21.0#readme 后续补充 ... |
3.问题/补充
1.如何搭建一个允许跨域访问的web server, 供开发测试. // 20201229 周二 TBD 暂定使用 nodeJS实现 预备使用 LANMP 实现~~~ 2. 使用PHP自带server跨域请求一直有问题, 原因TBD 使用nodeJS [express] mock server, 是可以正常响应的. 我们知道, 跨域是浏览器安全策略导致的, 而不是server导致 |
4.参考
http://www.ruanyifeng.com/blog/2016/04/cors.html //跨域资源共享 CORS 详解 -- 推荐阅读 https://wangdoc.com/javascript/bom/cors.html https://enable-cors.org/server_expressjs.html // CORS on ExpressJS https://github.com/facebook/create-react-app/blob/master/docusaurus/docs/proxying-api-requests-in-development.md // react 跨域解决方案 https://blog.csdn.net/william_n/article/details/108123718 // 浏览器何时发送一个OPTIONS请求? CORS[跨域资源共享] - 学习/实践 https://yunp.top/blog/index.php/2016/05/12/44/ // 跨域访问 |
后续补充
...