Skip to content

Commit

Permalink
Add header to support CORS preflight
Browse files Browse the repository at this point in the history
Need to respond with Access-Control-Allow-Headers within allowed
headers for prelight check on browser to work.
  • Loading branch information
richardhallett committed Jul 28, 2021
1 parent d0da95e commit 5133978
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions vendor/docker/webapp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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)') {
Expand All @@ -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;
}
Expand All @@ -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;
}

Expand Down

0 comments on commit 5133978

Please sign in to comment.