Fix GrampsWeb subpath: patch API/lang/font paths in JS at startup (STI-90)
GrampsWeb's frontend JS hardcodes absolute paths like "/api/...", "/lang/...", "/fonts/..." which bypass <base href>. These now get rewritten to "/ahnenforschung/api/..." etc. at container startup, matching both double-quoted and template-literal (backtick) patterns. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
23
compose.yml
23
compose.yml
@@ -210,11 +210,30 @@ services:
|
|||||||
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
|
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
|
||||||
SUBPATH="$$GRAMPSWEB_SUBPATH"
|
SUBPATH="$$GRAMPSWEB_SUBPATH"
|
||||||
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
|
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
|
||||||
echo "[grampsweb] Patching <base href> to $$SUBPATH ..."
|
echo "[grampsweb] Patching static files for subpath $$SUBPATH ..."
|
||||||
find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do
|
find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do
|
||||||
if grep -q '<base href="/">' "$$f" 2>/dev/null; then
|
if grep -q '<base href="/">' "$$f" 2>/dev/null; then
|
||||||
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" "$$f"
|
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" "$$f"
|
||||||
echo "[grampsweb] patched: $$f"
|
echo "[grampsweb] patched base href: $$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for f in /app/static/*.js; do
|
||||||
|
if [ -f "$$f" ] && grep -q '/api/' "$$f" 2>/dev/null; then
|
||||||
|
sed -i "s|\"/api/|\"$${SUBPATH}api/|g" "$$f"
|
||||||
|
sed -i 's|`/api/|`'"$${SUBPATH}"'api/|g' "$$f"
|
||||||
|
sed -i "s|\"/lang/|\"$${SUBPATH}lang/|g" "$$f"
|
||||||
|
sed -i 's|`/lang/|`'"$${SUBPATH}"'lang/|g' "$$f"
|
||||||
|
sed -i "s|\"/fonts/|\"$${SUBPATH}fonts/|g" "$$f"
|
||||||
|
sed -i 's|`/fonts/|`'"$${SUBPATH}"'fonts/|g' "$$f"
|
||||||
|
sed -i "s|\"/assets/|\"$${SUBPATH}assets/|g" "$$f"
|
||||||
|
sed -i 's|`/assets/|`'"$${SUBPATH}"'assets/|g' "$$f"
|
||||||
|
echo "[grampsweb] patched JS paths: $$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for f in /app/static/*.css; do
|
||||||
|
if [ -f "$$f" ] && grep -q '"/fonts/' "$$f" 2>/dev/null; then
|
||||||
|
sed -i "s|\"/fonts/|\"$${SUBPATH}fonts/|g" "$$f"
|
||||||
|
echo "[grampsweb] patched CSS paths: $$f"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "[grampsweb] Done."
|
echo "[grampsweb] Done."
|
||||||
|
|||||||
@@ -136,11 +136,30 @@ services:
|
|||||||
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
|
if [ -n "$$GRAMPSWEB_SUBPATH" ] && [ "$$GRAMPSWEB_SUBPATH" != "/" ]; then
|
||||||
SUBPATH="$$GRAMPSWEB_SUBPATH"
|
SUBPATH="$$GRAMPSWEB_SUBPATH"
|
||||||
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
|
case "$$SUBPATH" in */) ;; *) SUBPATH="$${SUBPATH}/" ;; esac
|
||||||
echo "[grampsweb] Patching <base href> to $$SUBPATH ..."
|
echo "[grampsweb] Patching static files for subpath $$SUBPATH ..."
|
||||||
find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do
|
find / -name index.html -path "*/gramps*" -o -name index.html -path "*/static/*" 2>/dev/null | while read f; do
|
||||||
if grep -q '<base href="/">' "$$f" 2>/dev/null; then
|
if grep -q '<base href="/">' "$$f" 2>/dev/null; then
|
||||||
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" "$$f"
|
sed -i "s|<base href=\"/\">|<base href=\"$$SUBPATH\">|g" "$$f"
|
||||||
echo "[grampsweb] patched: $$f"
|
echo "[grampsweb] patched base href: $$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for f in /app/static/*.js; do
|
||||||
|
if [ -f "$$f" ] && grep -q '/api/' "$$f" 2>/dev/null; then
|
||||||
|
sed -i "s|\"/api/|\"$${SUBPATH}api/|g" "$$f"
|
||||||
|
sed -i 's|`/api/|`'"$${SUBPATH}"'api/|g' "$$f"
|
||||||
|
sed -i "s|\"/lang/|\"$${SUBPATH}lang/|g" "$$f"
|
||||||
|
sed -i 's|`/lang/|`'"$${SUBPATH}"'lang/|g' "$$f"
|
||||||
|
sed -i "s|\"/fonts/|\"$${SUBPATH}fonts/|g" "$$f"
|
||||||
|
sed -i 's|`/fonts/|`'"$${SUBPATH}"'fonts/|g' "$$f"
|
||||||
|
sed -i "s|\"/assets/|\"$${SUBPATH}assets/|g" "$$f"
|
||||||
|
sed -i 's|`/assets/|`'"$${SUBPATH}"'assets/|g' "$$f"
|
||||||
|
echo "[grampsweb] patched JS paths: $$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for f in /app/static/*.css; do
|
||||||
|
if [ -f "$$f" ] && grep -q '"/fonts/' "$$f" 2>/dev/null; then
|
||||||
|
sed -i "s|\"/fonts/|\"$${SUBPATH}fonts/|g" "$$f"
|
||||||
|
echo "[grampsweb] patched CSS paths: $$f"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "[grampsweb] Done."
|
echo "[grampsweb] Done."
|
||||||
|
|||||||
Reference in New Issue
Block a user