Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doh.ffmuc.net.conf to add pre-flight CORS support. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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