Skip to content

Instantly share code, notes, and snippets.

@zguillez
Created March 1, 2023 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zguillez/fd1ea755e0568a94ba142be98a6f4767 to your computer and use it in GitHub Desktop.
Save zguillez/fd1ea755e0568a94ba142be98a6f4767 to your computer and use it in GitHub Desktop.
Allow cors in PHP
header("Content-Type: application/json;charset=utf-8");
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
header("Access-Control-Allow-Methods: POST, OPTIONS");
header("Allow: POST, OPTIONS");
$method = $_SERVER['REQUEST_METHOD'];
if ($method == "OPTIONS") {
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment