Skip to content

Instantly share code, notes, and snippets.

@melvincarvalho
Created April 10, 2016 15:38
Show Gist options
  • Select an option

  • Save melvincarvalho/e401f79f1c79a8a38c7c85bebfb85fb3 to your computer and use it in GitHub Desktop.

Select an option

Save melvincarvalho/e401f79f1c79a8a38c7c85bebfb85fb3 to your computer and use it in GitHub Desktop.
cors.php
<?php
if (isset($_SERVER['HTTP_ORIGIN'])) {
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
header('Access-Control-Allow-Credentials: true');
} else {
header('Access-Control-Allow-Origin : *');
}
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
exit(0);
}
header("Vary: Accept");
if (stristr($_SERVER["HTTP_ACCEPT"], "application/turtle")) {
header("Content-Type: application/turtle");
} else {
header("Content-Type: text/turtle");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment