Created
August 11, 2016 15:13
-
-
Save jayshields/912df25a8e66f42d42eb3b333d2b2120 to your computer and use it in GitHub Desktop.
Access-Control-Allow-Origin whitelist for Silex
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
$app->after(function(Request $request, Response $response){ | |
$access_whitelist = array('https://domain1.com', 'https://domain2.com', 'https://domain3.com'); | |
if(in_array($_SERVER['HTTP_ORIGIN'], $access_whitelist)) | |
$response->headers->set('Access-Control-Allow-Origin', $_SERVER['HTTP_ORIGIN']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment