Describe a better way to enforce Content-Type in nginx

add_header will not override the Content-Type header set by the server,
but will instead add another header below, which is obviously not ideal.

The proposed change will instead tell nginx to set the correct value for
this header straight away.
This commit is contained in:
Ticho 34782694 2022-11-08 15:56:24 +00:00
parent ccdaaceb33
commit 09015f113c

View file

@ -121,12 +121,12 @@ So...step by step:
location /.well-known/matrix/server { location /.well-known/matrix/server {
return 200 '{"m.server": "<SUBDOMAIN>.<DOMAIN>:443"}'; return 200 '{"m.server": "<SUBDOMAIN>.<DOMAIN>:443"}';
add_header Content-Type application/json; types { } default_type "application/json; charset=utf-8";
} }
location /.well-known/matrix/client { location /.well-known/matrix/client {
return 200 '{"m.homeserver": {"base_url": "https://<SUBDOMAIN>.<DOMAIN>"}}'; return 200 '{"m.homeserver": {"base_url": "https://<SUBDOMAIN>.<DOMAIN>"}}';
add_header Content-Type application/json; types { } default_type "application/json; charset=utf-8";
add_header "Access-Control-Allow-Origin" *; add_header "Access-Control-Allow-Origin" *;
} }