Skip to content

Instantly share code, notes, and snippets.

@dazecoop
Created November 1, 2021 16:21
Show Gist options
  • Save dazecoop/37f5f82d795d849c9e217b8b43136f44 to your computer and use it in GitHub Desktop.
Save dazecoop/37f5f82d795d849c9e217b8b43136f44 to your computer and use it in GitHub Desktop.
Basic PHP CORS
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, DELETE, PUT, PATCH, OPTIONS');
header('Access-Control-Allow-Headers: token, Content-Type');
header('Access-Control-Max-Age: 1728000');
header('Content-Length: 0');
header('Content-Type: text/plain');
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment