Skip to content

Commit

Permalink
fix(cors): update CORS methods to include OPTIONS and adjust header s…
Browse files Browse the repository at this point in the history
…yntax
  • Loading branch information
AliMD committed Nov 11, 2024
1 parent 6ace201 commit 0ec647b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion nginx-core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ENV NGINX_ACCESS_LOG="/var/log/nginx/access.log json" \
NGINX_ENTRYPOINT_QUIET_LOGS="" \
NGINX_CORS_ENABLE="" \
NGINX_CORS_ORIGIN="*" \
NGINX_CORS_METHODS="GET" \
NGINX_CORS_METHODS="GET, OPTIONS" \
NGINX_CORS_HEADERS="*" \
NGINX_CORS_MAXAGE=86400

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN;
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;
add_header 'Access-Control-Allow-Origin' '$NGINX_CORS_ORIGIN';
add_header 'Access-Control-Allow-Methods' '$NGINX_CORS_METHODS';
add_header 'Access-Control-Allow-Headers' '$NGINX_CORS_HEADERS';
add_header 'Access-Control-Max-Age' '$NGINX_CORS_MAXAGE';

# Handle OPTIONS requests (preflight requests for complex requests)
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN;
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;
add_header 'Access-Control-Allow-Origin' '$NGINX_CORS_ORIGIN';
add_header 'Access-Control-Allow-Methods' '$NGINX_CORS_METHODS';
add_header 'Access-Control-Allow-Headers' '$NGINX_CORS_HEADERS';
add_header 'Access-Control-Max-Age' '$NGINX_CORS_MAXAGE';
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;

Expand Down

0 comments on commit 0ec647b

Please sign in to comment.