Skip to content

Commit

Permalink
Merge pull request #2 from jacwright/jacwrightgh-115
Browse files Browse the repository at this point in the history
Fixing CORS multiple origins header
  • Loading branch information
jgonzalez-stack authored Sep 24, 2020
2 parents ee53e35 + 119eee4 commit fe95d13
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions source/Jacwright/RestServer/RestServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,7 @@ private function corsHeaders() {
if (in_array($currentOrigin, $allowedOrigin) || in_array('*', $allowedOrigin)) {
$allowedOrigin = array($currentOrigin); // array ; if there is a match then only one is enough
}
foreach($allowedOrigin as $allowed_origin) { // to support multiple origins
header("Access-Control-Allow-Origin: $allowed_origin");
}
header('Access-Control-Allow-Origin: ' . implode(', ', $allowedOrigin));
header('Access-Control-Allow-Methods: GET,POST,PUT,DELETE,OPTIONS');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: X-Requested-With, content-type, access-control-allow-origin, access-control-allow-methods, access-control-allow-headers, Authorization');
Expand Down

0 comments on commit fe95d13

Please sign in to comment.