Skip to content

Instantly share code, notes, and snippets.

@sserbest
Created June 30, 2017 15:45
Show Gist options
  • Save sserbest/7fbaca45fc44ae84b313f1baaa3922fd to your computer and use it in GitHub Desktop.
Save sserbest/7fbaca45fc44ae84b313f1baaa3922fd to your computer and use it in GitHub Desktop.
PHP CORS
public function __construct()
{
parent::__construct();
//CORS don't remove
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: X-API-KEY, Origin, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method");
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
$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