在本地测试CORS

I have an Api that accepts CORS requests.

I was trying to test this application by remapping my hosts file in c:\windows\System32\drivers\etc\hosts as follows:

127.0.0.1 localhost.mydomain.com

So I hosted my calling application off:

localhost.mydomain.com

And my Api off:

localhost

And found that the Api call returned Error: Access denied. in IE10

However in Chrome the same configuration worked fine.

I then fiddled for some time, I understand that IE10 fully support CORS so was surprised this did not work.

Eventually I got the CORS requests to work with another entry in my hosts file

127.0.0.1 localapi.mydomain.com

Is there something specific that stops IE10 being able to call Localhost when on another domain?

Thanks

Just an educated guess: IE has defined security zones that guide, what is allowed and what not. It might be, that localhost is placed in the internal, trusted, zone, while the .com is placed in the "wild web" zone with fewer permissions. Thus IE might voluntarily cut the connection between both.

Try to place your local domains via "Internet Options" > "Security Zones" in the "internal zone" and see, if this fixes the access problem.