No 'Access-Control-Allow-Origin' header - Same Domain?

岁酱吖の 提交于 2019-12-13 19:26:30

问题


Today I attempted to browse a new feature recently deployed to our testing environment (NOT LOCAL). After navigating to the new feature I was met with a blank page. Confused, I checked Chrome's console and found an error:

XMLHttpRequest cannot load https://test.mytestsite.com/SomeApplication/api/SomeController/SomeMethod/8?Id=523283&SecondId=1612w3426653. 
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://test.mytestsite.com' is therefore not allowed access.

This code makes an ajax call to a WebAPI (on the same domain) to retrieve some information on document.Ready. I understand the error and I'm familiar with it's typical cause. However, this call is being made from within the same domain AND it works for the other developers on my team.

Symptoms: - Does not work for IE or Chrome/Incognito - Does work for FireFox - Works on all browsers for at least 4 other developers on the same domain that I reside on. (Indicating to me that this is an environmental issue)

Possible causes: - I was doing some CORS research several weeks ago and perhaps I configured some Windows 7 setting to cause this to happen?

Google is saturated with the standard CORS issues, so I'm asking here and hopefully someone can help.


回答1:


The issue at hand was due to inconsistencies between environments.

In our production environment SSL is enforced with a redirect in IIS, while in our testing environment it is not. I was navigating to the site via a bookmark using http. Updating the bookmark, as @epascarello suggested, fixed the problem.



来源:https://stackoverflow.com/questions/20055663/no-access-control-allow-origin-header-same-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!