Last active
January 29, 2022 11:02
-
-
Save josfaber/1f6b974ea3c87bf53755b06210453b71 to your computer and use it in GitHub Desktop.
Allow specific domains and url's | Access-Control-Allow-Origin in 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
$origin = $_SERVER['HTTP_ORIGIN']; | |
$allowed_domains = [ | |
'http://localhost', | |
'http://localhost:8080', | |
'http://localhost:8081', | |
'https://example.com', | |
'https://test.example.com', | |
'http://example.net', | |
]; | |
if (in_array($origin, $allowed_domains)) { | |
header('Access-Control-Allow-Origin: ' . $origin); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment