-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nginx-core): streamline CORS handling in configuration template
- Loading branch information
Showing
1 changed file
with
2 additions
and
8 deletions.
There are no files selected for viewing
10 changes: 2 additions & 8 deletions
10
nginx-core/etc/nginx/templates/location.d/70-cors.conf.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
# Method 1: Allow specific origin (Recommended for security) | ||
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN; | ||
|
||
# Allow specific methods (GET, POST, PUT, DELETE, OPTIONS) | ||
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS; | ||
|
||
# Allow specific headers | ||
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS; | ||
|
||
# Cache preflight requests for 24 hours (improves performance) | ||
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE; | ||
|
||
# Handle OPTIONS requests (preflight requests for complex requests) | ||
if ($request_method = 'OPTIONS') { | ||
# Handle OPTIONS requests (preflight requests for complex requests) | ||
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; | ||
|
||
return 204; | ||
} |