Does Safari 5.1 ignore Access-Control-Allow-Origin

2019-05-12 17:25发布

问题:

Trying to make a cross protocol, same domain request from https to http. I have set the response headers to read Access-Control-Allow-Origin: * which is indeed working in Chrome. However, it doesn't work in Safari.

Is Safari ignoring the wildcard? Is it giving the wrong error and indeed there is a different problem?

回答1:

Found out that this indeed not the case. Instead what is happening is that Safari is making an OPTIONS call to the server before the AJAX call, and in my case my server framework doesn't support it without extra coding.

You can see it here in the docs:

http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/SafariJSProgTopics/Articles/XHR.html