Created
July 24, 2020 16:06
-
-
Save adamculpepper/54a7b59c79e4fc3a7013e626bb25c8b1 to your computer and use it in GitHub Desktop.
PHP Proxy for JSON with wildcard 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('Access-Control-Allow-Origin: *'); | |
header("Content-Type: application/json; charset=utf-8"); | |
$url = htmlspecialchars($_GET['url']); | |
if ($url) { | |
$content = file_get_contents($url); | |
} else { | |
$content = 'error'; | |
} | |
echo json_encode(json_decode($content), JSON_PRETTY_PRINT); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment