【发布时间】:2023-03-11 09:18:02
【问题描述】:
我们正在实现一个基于 AngularJS 的应用程序,它使用托管在不同域中的 REST Web 服务。以下脚本用于 CORS,它在 Chrome 和 FireFox 上完美运行。身份验证时在 IE9 和 Safari 中存在问题。似乎问题出在这些浏览器中的 withCredentials 属性上。 IE和Safari还有其他方式支持CORS吗?
<script type="text/javascript">
XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function(vData) {
this.withCredentials = true;
this.realSend.apply(this, arguments);
};
</script>
【问题讨论】:
-
如果您询问 IE9 或更早版本中的凭据跨源请求,答案是“不支持”。这些浏览器仅通过 XDomainRequest 提供有限的 CORS 支持。
-
没有。我要IE10+版本
标签: javascript angularjs cors