From 119eee48bd76520c83c4a26f7b3dbce0adcc24d5 Mon Sep 17 00:00:00 2001 From: Jacob Wright Date: Tue, 16 Oct 2018 21:24:19 -0600 Subject: [PATCH] Fixing CORS multiple origins header Addresses #115 --- source/Jacwright/RestServer/RestServer.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/Jacwright/RestServer/RestServer.php b/source/Jacwright/RestServer/RestServer.php index 9e84b47..c464d62 100755 --- a/source/Jacwright/RestServer/RestServer.php +++ b/source/Jacwright/RestServer/RestServer.php @@ -568,9 +568,7 @@ private function corsHeaders() { if (in_array($currentOrigin, $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-Credential: true'); header('Access-Control-Allow-Headers: X-Requested-With, content-type, access-control-allow-origin, access-control-allow-methods, access-control-allow-headers, Authorization');