Skip to content

Instantly share code, notes, and snippets.

@BlackDante
Created March 30, 2016 12:51
Show Gist options
  • Save BlackDante/c927185496becef6534c60740d56555b to your computer and use it in GitHub Desktop.
Save BlackDante/c927185496becef6534c60740d56555b to your computer and use it in GitHub Desktop.
<?php
if (isset($_GET['origin'])) {
switch($_GET['origin']) {
case '*':
header("Access-Control-Allow-Origin: *");
break;
case 'www':
$server = isset($_SERVER['HTTP_REFERER']) ? "http://" . parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST) : null;
header("Access-Control-Allow-Origin: $server");
break;
}
}
echo json_encode(['status' => 'ok']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment