Skip to content

Commit

Permalink
handle preflight cors
Browse files Browse the repository at this point in the history
  • Loading branch information
matyson committed May 20, 2024
1 parent a29a555 commit bb59ae6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,20 @@ http {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

add_header Access-Control-Allow-Origin '*' always;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always;
add_header Access-Control-Allow-Headers 'Content-Type, Origin, Accept, Authorization, X-Request-With, X-API-KEY' always;
add_header Access-Control-Allow-Credentials 'true' always;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Origin, Accept, Authorization, X-Request-With, X-API-KEY';
add_header 'Access-Control-Allow-Credentials' 'true';

if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Content-Type, Origin, Accept, Authorization, X-Request-With, X-API-KEY';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Content-Length' 0;
add_header 'Content-Type' 'text/plain; charset=utf-8';
return 204;
}
}
}
}

0 comments on commit bb59ae6

Please sign in to comment.