HTTP preflight (OPTIONS) request fails in IE only

前端 未结 2 1787
悲&欢浪女
悲&欢浪女 2020-12-11 11:24

I trying to make a POST request to my REST API. Here is the code snippet (using AngularJS):

        $http({
            method: \'POST\',
            url: ur         


        
相关标签:
2条回答
  • 2020-12-11 11:49

    You could add sites to Trusted zone in IE settings and set "Access data sources across domains" to Enable (not Prompt):

    It works not only for IE 9, but 10+ as well.

    More on this: https://www.webdavsystem.com/ajax/programming/cross_origin_requests

    0 讨论(0)
  • 2020-12-11 12:00

    I found the reason for all that mess.

    The API service and the website were located on the same domain, but on different ports. To be specific, the API service was located on:

    myDomain.com/apiService

    and the website was located on:

    myDomain.com:44443/webSite

    Thus, when the web browser was initializing the call from:

    myDomain.com:44443/webSite/page1

    to:

    myDomain.com/apiService/service1

    Internet Explorer was blocking the call because of the CORS. For some reason, Chrome was less strict in that matter, because it succeeded to make the call to the API.

    To make it work in Internet Explorer, I moved the website to the same port as the API:

    myDomain.com/apiService

    myDomain.com/webSite

    0 讨论(0)
提交回复
热议问题