为什么浏览器 API 会限制跨域请求? [英] Why do browser APIs restrict cross-domain requests?

查看:22
本文介绍了为什么浏览器 API 会限制跨域请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XMLHttpRequest 需要 CORS 才能跨域工作.对于网络字体、WebGL 纹理和其他一些东西也是如此.一般来说,所有新的 API 似乎都有这个限制.

XMLHttpRequests require CORS to work cross-domain. Similarly for web fonts, WebGL textures, and a few other things. In general all new APIs seem to have this restriction.

为什么?

绕过它非常容易:只需要一个简单的服务器端代理.换句话说,服务器端代码不被禁止做跨域请求;为什么是客户端代码?这如何为任何人提供任何安全保障?

It's so easy to circumvent: all it takes is a simple server-side proxy. In other words, server-side code isn't prohibited from doing cross-domain requests; why is client-side code? How does this give any security, to anyone?

而且它是如此不一致:我不能 XMLHttpRequest,但我可以

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆