“Origin null is not allowed by Access-Control-Allow-Origin” error for request made by application running from a file:// URL

后端 未结 17 1513
孤城傲影
孤城傲影 2020-11-21 04:42

I\'m developing a page that pulls images from Flickr and Panoramio via jQuery\'s AJAX support.

The Flickr side is working fine, but when I try to $.get(url, ca

17条回答
  •  星月不相逢
    2020-11-21 05:21

    Folks,

    I ran into a similar issue. But using Fiddler, I was able to get at the issue. The problem is that the client URL that is configured in the CORS implementation on the Web API side must not have a trailing forward-slash. After submitting your request via Google Chrome and inspect the TextView tab of the Headers section of Fiddler, the error message states something like this:

    *"The specified policy origin your_client_url:/' is invalid. It cannot end with a forward slash."

    This is real quirky because it worked without any issues on Internet Explorer, but gave me a headache when testing using Google Chrome.

    I removed the forward-slash in the CORS code and recompiled the Web API, and now the API is accessible via Chrome and Internet Explorer without any issues. Please give this a shot.

    Thanks, Andy

提交回复
热议问题