fix(dawarich): serve .mjs MapLibre modules as JavaScript (#18304)

Since Dawarich 1.15.1 the importmap pins maplibre-gl to
/maplibre/<version>/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 <noreply@anthropic.com>
This commit is contained in:
Riccardo Baral
2026-10-29 13:53:13 +01:00
committed by GitHub
parent 773d8e00fc
commit 08e2f99522
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -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
+6
View File
@@ -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";