From 08e2f9952264b2aa32ee16ce8597ae125652c445 Mon Sep 17 00:00:00 2001 From: Riccardo Baral <5872112+ricbaral@users.noreply.github.com> Date: Thu, 29 Oct 2026 13:53:13 +0100 Subject: [PATCH] fix(dawarich): serve .mjs MapLibre modules as JavaScript (#18304) Since Dawarich 1.15.1 the importmap pins maplibre-gl to /maplibre//maplibre-gl.mjs in public/. Debian's nginx mime.types has no mjs entry, so the vhost served it as application/octet-stream and browsers refused to load the module: blank map, map controllers fail. Add a .mjs location (text/javascript, as Rails serves it upstream) to the install heredoc, and insert it into existing vhosts from update_script() before the release check, applied via nginx_enable_site. Co-authored-by: Claude Opus 5.5 --- ct/dawarich.sh | 7 +++++++ install/dawarich-install.sh | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/ct/dawarich.sh b/ct/dawarich.sh index 4c5595a24..03149aa0b 100644 --- a/ct/dawarich.sh +++ b/ct/dawarich.sh @@ -33,6 +33,13 @@ function update_script() { ensure_dependencies libgeos++-dev libxml2-dev libxslt-dev libjemalloc-dev + if [[ -f /etc/nginx/sites-available/dawarich.conf ]] && ! grep -q '\.mjs\$' /etc/nginx/sites-available/dawarich.conf; then + msg_info "Fixing MapLibre delivery in Nginx" + sed -i '/location ~ \^\/(assets|packs)\/ {/i\ location ~ \\.mjs$ {\n types { }\n default_type text/javascript;\n try_files $uri @rails;\n }\n' /etc/nginx/sites-available/dawarich.conf + nginx_enable_site dawarich.conf + msg_ok "Fixed MapLibre delivery in Nginx" + fi + if check_for_gh_release "dawarich" "Freika/dawarich"; then msg_info "Stopping Services" systemctl stop dawarich-web dawarich-worker diff --git a/install/dawarich-install.sh b/install/dawarich-install.sh index ad0565a40..87593908b 100644 --- a/install/dawarich-install.sh +++ b/install/dawarich-install.sh @@ -150,6 +150,12 @@ server { root /opt/dawarich/app/public; client_max_body_size 100M; + location ~ \.mjs\$ { + types { } + default_type text/javascript; + try_files \$uri @rails; + } + location ~ ^/(assets|packs)/ { expires max; add_header Cache-Control "public, immutable";