XMLHttpRequest Access Denied with AngularJS on any IE version below 10

前端 未结 3 1228
我寻月下人不归
我寻月下人不归 2020-12-02 07:14

While viewing my application on any Microsoft IE browser of version earlier than 10, I get the following weird error at the console:

3条回答
  •  爱一瞬间的悲伤
    2020-12-02 07:51

    Of course your problem is CORS related. IE10 uses a real XmlHttpRequest, but before that, IE did not. By far, the easiest way I have found to resolve these types of issues is to use apache or nginx to proxy the API. For example, with nginx, in your server {} block:

    location /api {
       proxy_pass http://my.server.name:12345/v1;
       proxy_redirect off;
    }
    

    Note that even jQuery does not support XDomainRequest and CORS outright, you have to add a plugin to get XDR. Also note, XDR has some severe limitations around CORS.

提交回复
热议问题