我们正在实现一个基于 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>