Created
April 5, 2019 19:05
-
-
Save kimlombard/540661e8a348926bc644d9546ceb0193 to your computer and use it in GitHub Desktop.
[CORS] Dealing with CORS issues by sending the appropriate headers #php
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 | |
| 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