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
Try with:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
I'm sorry but using multiple values on Access-Control-Allow-Origin is not permited. Either you use the wildcard "*" or use a single domain.
Another approach is to do a small script and change that value based on the origin of the request, comparing it against a list of posible domains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With