Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Created July 24, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamculpepper/54a7b59c79e4fc3a7013e626bb25c8b1 to your computer and use it in GitHub Desktop.
Save adamculpepper/54a7b59c79e4fc3a7013e626bb25c8b1 to your computer and use it in GitHub Desktop.
PHP Proxy for JSON with wildcard CORS
<?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