Created
July 7, 2020 04:15
-
-
Save devig/8313c90c6abe3db58a3f92a6fd0c7600 to your computer and use it in GitHub Desktop.
Check 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
<?php | |
header('Accept : application/json'); | |
header('Access-Control-Allow-Origin : *'); | |
header('Access-Control-Allow-Methods : POST,GET,OPTIONS,PUT,DELETE'); | |
header('X-Requested-With : XMLHttpRequest'); | |
header('Access-Control-Allow-Headers : Content-Type,Authorization'); | |
//https://cors-anywhere.herokuapp.com/ | |
if (!empty($_SERVER["REQUEST_METHOD"]) && $_SERVER['REQUEST_METHOD']=='OPTIONS') { | |
header("HTTP/1.1 204 NO CONTENT"); | |
die; | |
} | |
$arr = $arr = $_REQUEST; | |
header("X-Blablabla: " . $_SERVER['REQUEST_METHOD']); | |
echo json_encode($arr); | |
die; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment