From 2f3dea9b282a991808243c1775851231776ac89b Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 25 Feb 2022 13:14:49 +0100 Subject: ... --- hosts/surtr/matrix/default.nix | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hosts/surtr/matrix/default.nix b/hosts/surtr/matrix/default.nix index 02e2c7b9..c35153e5 100644 --- a/hosts/surtr/matrix/default.nix +++ b/hosts/surtr/matrix/default.nix @@ -81,18 +81,21 @@ ]; extraConfig = '' add_header Strict-Transport-Security "max-age=63072000" always; - - add_header Access-Control-Allow-Origin '*'; - add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS'; - add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization'; - add_header Access-Control-Max-Age 7200; ''; - locations = { + locations = let + corsHeaders = '' + add_header Access-Control-Allow-Origin '*'; + add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS'; + add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization'; + add_header Access-Control-Max-Age 7200; + ''; + in { "/_matrix".proxyPass = "http://matrix-synapse"; "/_synapse/client".proxyPass = "http://matrix-synapse"; "= /.well-known/matrix/server" = { extraConfig = '' default_type application/json; + ${corsHeaders} ''; return = "200 '${builtins.toJSON { "m.server" = "synapse.li:443"; @@ -101,6 +104,7 @@ "= /.well-known/matrix/client" = { extraConfig = '' default_type application/json; + ${corsHeaders} ''; return = "200 '${builtins.toJSON { "m.homeserver" = { "base_url" = "https://synapse.li"; }; -- cgit v1.2.3