Created
June 30, 2017 15:45
-
-
Save sserbest/7fbaca45fc44ae84b313f1baaa3922fd to your computer and use it in GitHub Desktop.
PHP CORS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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