[OpenLayers-Users] CORS
Tomas Straupis
tomasstraupis at gmail.com
Fri Jan 6 01:06:48 EST 2012
Hello
The only missing part in php code was handling of non preflight, so
the final code in php should be like this (note the "else" part):
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
// return only the headers and not the content
// only allow CORS if we're doing a GET - i.e. no saving for now.
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']) &&
$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'] == 'GET') {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: X-Requested-With');
}
exit;
} else {
header('Access-Control-Allow-Origin: *');
}
And now it works. Thank you for help!
--
Tomas Straupis
More information about the Users
mailing list