Skip to content

Instantly share code, notes, and snippets.

@zguillez
Created March 1, 2023 11:28
Embed
What would you like to do?
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