Skip to content

Commit

Permalink
Update doh.ffmuc.net.conf to support pre-flight requests (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellieschieder authored Apr 9, 2024
1 parent 4ffa575 commit ccb0848
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion nginx/domains/doh.ffmuc.net.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,19 @@ server {

# Add CORS Header to allow access via JavaScript see: https://github.com/freifunkMUC/ffmuc-salt-public/issues/125
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' '*' always;

# Allow pre-flight request see: https://github.com/freifunkMUC/ffmuc-salt-public/issues/162
# If a Browser is using pre-flight request using OPTIONS method, return 204 and an empty body.
if ($request_method = 'OPTIONS') {
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
# Allows caching of CORS response for upto 1 day;
# Firefox overwrites to max 1 day; Chrome overwrites to max 2hr
add_header 'Access-Control-Max-Age' 86400;
return 204;
}
}
location / {
if ( $request_method = GET ) {
Expand Down

0 comments on commit ccb0848

Please sign in to comment.