Skip to content

Instantly share code, notes, and snippets.

@rjcorwin
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save rjcorwin/5cc4dccdc0a560bb0fe8 to your computer and use it in GitHub Desktop.

Select an option

Save rjcorwin/5cc4dccdc0a560bb0fe8 to your computer and use it in GitHub Desktop.
$allowed_cors_origins = array('http://localhost:9000/', 'http://isovera.github.io/');
if (in_array($_SERVER['HTTP_REFERER'], $allowed_cors_origins)) {
header("Access-Control-Allow-Origin: " . substr($_SERVER['HTTP_REFERER'], 0, -1));
header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");
header("Access-Control-Allow-Headers: content-type, X-CSRF-Token");
header("Access-Control-Allow-Credentials: true");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment