From 2a3577baff02bfa2494fa91e3e4d77a394ebb7b7 Mon Sep 17 00:00:00 2001 From: SysAdmin Agent Date: Tue, 24 Mar 2026 12:33:18 +0000 Subject: [PATCH] Fix GrampsWeb: patch service worker to respect subpath (STI-90) The GrampsWeb service worker was serving index.html for ALL navigation requests (including Django app routes), hijacking the entire domain. Patched sw.js at startup to: - Use subpath-prefixed index.html in createHandlerBoundToURL - Update denylist regex to match subpath API routes Co-Authored-By: Claude Opus 4.6 --- compose.yml | 6 ++++++ deploy-production/docker-compose.prod.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/compose.yml b/compose.yml index db90232..81b5bba 100644 --- a/compose.yml +++ b/compose.yml @@ -232,6 +232,12 @@ services: echo "[grampsweb] patched JS paths: $$f" fi done + if [ -f /app/static/sw.js ]; then + sed -i "s|createHandlerBoundToURL(\"/index.html\")|createHandlerBoundToURL(\"$${SUBPATH}index.html\")|g" /app/static/sw.js + SUBPATH_BS=$$(echo "$$SUBPATH" | sed "s|/|\\\\\\\\/|g") + sed -i "s|\\^\\\\/api|\\^$${SUBPATH_BS}api|g" /app/static/sw.js + echo "[grampsweb] patched sw.js navigation routes" + fi find /app/static -name '*.css' 2>/dev/null | while read f; do if grep -q '\.\./fonts/' "$$f" 2>/dev/null; then sed -i "s|'../fonts/|'fonts/|g" "$$f" diff --git a/deploy-production/docker-compose.prod.yml b/deploy-production/docker-compose.prod.yml index f6ee61d..32b6501 100644 --- a/deploy-production/docker-compose.prod.yml +++ b/deploy-production/docker-compose.prod.yml @@ -158,6 +158,12 @@ services: echo "[grampsweb] patched JS paths: $$f" fi done + if [ -f /app/static/sw.js ]; then + sed -i "s|createHandlerBoundToURL(\"/index.html\")|createHandlerBoundToURL(\"$${SUBPATH}index.html\")|g" /app/static/sw.js + SUBPATH_BS=$$(echo "$$SUBPATH" | sed "s|/|\\\\\\\\/|g") + sed -i "s|\\^\\\\/api|\\^$${SUBPATH_BS}api|g" /app/static/sw.js + echo "[grampsweb] patched sw.js navigation routes" + fi find /app/static -name '*.css' 2>/dev/null | while read f; do if grep -q '\.\./fonts/' "$$f" 2>/dev/null; then sed -i "s|'../fonts/|'fonts/|g" "$$f"