mercredi 2 décembre 2015

Access-Control-Allow-Origin with www

in my PHP file, I set the allowed origins like this:

header("Access-Control-Allow-Origin: http://example.com");
header("Access-Control-Allow-Origin: http://www.example.com");

But when the webserver or the browser translates

http://www.example.com

into

www.example.com

I only get this error message from chrome (e.g.)

XMLHttpRequest cannot load http://ift.tt/1ctW2qQ. 
The 'Access-Control-Allow-Origin' header contains the invalid value
www.example.com'. Origin 'http://www.example.com' is
therefore not allowed access.

So what is the correct syntax for the header if I want to add any domain like "www.example.com"??

Cheers guys!!

Aucun commentaire:

Enregistrer un commentaire