CORS header ‘Access-Control-Allow-Origin’ does not match ‘(null)’, but it is not null

symlink picture symlink · Feb 20, 2017 · Viewed 7.4k times · Source

I have a simple AJAX request that calls http://myexamplefeed.com/feed/23213

I just moved this site to a new server, and all of a sudden I'm getting this error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://myexamplefeed.com/feed/23213. (Reason: CORS header ‘Access-Control-Allow-Origin’ does not match ‘(null)’).

The thing is, in my .htaccess file I've tried to match *:

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin: *
</IfModule>

and http://myexamplefeed.com:

<IfModule mod_headers.c>
  Header set Access-Control-Allow-Origin: "http://myexamplefeed.com"
</IfModule>

and I still get the CORS header ‘Access-Control-Allow-Origin’ does not match ‘(null)’ error.

Isn't null referring to the Header set Access-Control-Allow-Origin value, and shouldn't I be able to alter it in my .htaccess file?


UPDATE: That was in Firefox. In Chrome I'm getting this message:

The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed

Answer

Croises picture Croises · Feb 20, 2017

Try with:

<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>