HTTP preflight (OPTIONS) request fails in IE only

前端 未结 2 1794
悲&欢浪女
悲&欢浪女 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 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

提交回复
热议问题