From 951c434ef25926a26946e49f45488d49ebdf9f07 Mon Sep 17 00:00:00 2001 From: SysAdmin Agent Date: Mon, 23 Mar 2026 23:23:28 +0000 Subject: [PATCH] Fix GrampsWeb subpath: use nginx sub_filter for rewrite (STI-93) GrampsWeb's SPA has hardcoded at build time. The GRAMPSWEB_BASE_URL env var is a full URL for API/OIDC, not a path prefix. This means assets always load from root, hitting Django instead of GrampsWeb. Fix: nginx sub_filter rewrites to so the browser resolves all SPA assets under the correct subpath. Also revert BASE_URL default to a proper URL (not a path). Co-Authored-By: Claude Opus 4.6 --- compose.yml | 2 +- deploy-production/nginx.conf | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/compose.yml b/compose.yml index 425efcd..40856ac 100644 --- a/compose.yml +++ b/compose.yml @@ -197,7 +197,7 @@ services: - GRAMPSWEB_ADMIN_EMAIL=${GRAMPSWEB_ADMIN_EMAIL} - GRAMPSWEB_ADMIN_PASSWORD=${GRAMPSWEB_ADMIN_PASSWORD} - GRAMPSWEB_TREE=${GRAMPSWEB_TREE:-Stiftung} - - GRAMPSWEB_BASE_URL=${GRAMPSWEB_BASE_URL:-/ahnenforschung} + - GRAMPSWEB_BASE_URL=${GRAMPSWEB_BASE_URL:-http://localhost:8090} - GRAMPSWEB_CELERY_CONFIG__broker_url=redis://redis:6379/0 - GRAMPSWEB_CELERY_CONFIG__result_backend=redis://redis:6379/0 - GRAMPSWEB_RATELIMIT_STORAGE_URI=redis://redis:6379/1 diff --git a/deploy-production/nginx.conf b/deploy-production/nginx.conf index da57054..7ee8f8e 100644 --- a/deploy-production/nginx.conf +++ b/deploy-production/nginx.conf @@ -83,6 +83,8 @@ server { } # GrampsWeb Ahnenforschung + # GrampsWeb SPA has hardcoded — sub_filter rewrites it + # so asset URLs resolve under /ahnenforschung/ instead of / location /ahnenforschung/ { proxy_pass http://127.0.0.1:8090/; proxy_set_header Host $host; @@ -91,7 +93,14 @@ server { proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Script-Name /ahnenforschung; - # WebSocket support (GrampsWeb uses SSE/WS for real-time updates) + # Rewrite to + # so the SPA loads JS/CSS from the correct subpath + proxy_set_header Accept-Encoding ""; + sub_filter '' ''; + sub_filter_once on; + sub_filter_types text/html; + + # WebSocket support proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";