Skip to content

Instantly share code, notes, and snippets.

@programarivm
Created July 12, 2020 14:45
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 programarivm/a626b0871abe9657c27a179743fb5774 to your computer and use it in GitHub Desktop.
Save programarivm/a626b0871abe9657c27a179743fb5774 to your computer and use it in GitHub Desktop.
wide-open CORS set up
<?php
require realpath(dirname(__FILE__)) .'/../src/bootstrap.php';
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range");
switch (true) {
case '/api/query' === $_SERVER['REQUEST_URI'] && $_SERVER['REQUEST_METHOD'] === 'POST':
require APP_PATH . '/src/Api/Query.php';
exit;
case $_SERVER['REQUEST_METHOD'] === 'OPTIONS':
http_response_code(204);
exit;
default:
http_response_code(404);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment