From 5133978b87958c524c0bf6539aafe745047db3a1 Mon Sep 17 00:00:00 2001 From: Richard Hallett Date: Wed, 28 Jul 2021 12:05:58 +0200 Subject: [PATCH] Add header to support CORS preflight Need to respond with Access-Control-Allow-Headers within allowed headers for prelight check on browser to work. --- vendor/docker/webapp.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/docker/webapp.conf b/vendor/docker/webapp.conf index ac32cd2b7..559940fa1 100644 --- a/vendor/docker/webapp.conf +++ b/vendor/docker/webapp.conf @@ -11,7 +11,7 @@ server { error_log stderr; - location / { + location / { # enable CORS set $cors 'true'; # if ($http_origin ~* 'https?://(localhost:3000|localhost:4200|doi.stage.datacite.org|commons.stage.datacite.org|doi.datacite.org|commons.datacite.org)') { @@ -23,7 +23,7 @@ server { add_header 'Access-Control-Allow-Origin' "$http_origin" always; add_header 'Access-Control-Allow-Credentials' 'true' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With' always; + add_header 'Access-Control-Allow-Headers' 'Accept,Access-Control-Allow-Headers,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With' always; # required to be able to read Authorization header in frontend add_header 'Access-Control-Expose-Headers' 'Authorization' always; } @@ -33,15 +33,15 @@ server { add_header 'Access-Control-Allow-Origin' "$http_origin"; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, PATCH, DELETE, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'; + add_header 'Access-Control-Allow-Headers' 'Accept,Access-Control-Allow-Headers,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } } - - location = / { + + location = / { return 301 https://support.datacite.org/docs/api; }