Skip to content

Instantly share code, notes, and snippets.

@kimlombard
Created April 5, 2019 19:05
Show Gist options
  • Select an option

  • Save kimlombard/540661e8a348926bc644d9546ceb0193 to your computer and use it in GitHub Desktop.

Select an option

Save kimlombard/540661e8a348926bc644d9546ceb0193 to your computer and use it in GitHub Desktop.
[CORS] Dealing with CORS issues by sending the appropriate headers #php
<?php
require 'vendor/autoload.php';
Flight::route('/', function(){
echo 'hello world!';
});
Flight::route('/cors', function(){
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type');
return Flight::json(array('data' => 'success'));
});
Flight::start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment