fix: remove path-rewriting sed that doubled BASE_PATH in <base> tag
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m43s
CI / docker (push) Successful in 1m9s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 36s

The second sed matched the just-injected <base href="/server/"> and
rewrote it to <base href="/server/server/">. Since Vite builds with
base: './' (relative paths), the <base> tag alone is sufficient.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-05 23:52:30 +02:00
parent 44f3821df4
commit 5b7c92848d

View File

@@ -1,6 +1,8 @@
#!/bin/sh
# Inject <base> tag into index.html when BASE_PATH is set.
# This allows the SPA to be served from a subpath (e.g., /server/).
# Vite builds with base: './' (relative paths), so the <base> tag
# is sufficient — no asset path rewriting needed.
# Default: / (standalone mode, no <base> tag needed).
BASE_PATH="${BASE_PATH:-/}"
@@ -10,11 +12,9 @@ if [ "$BASE_PATH" != "/" ]; then
BASE_PATH=$(echo "$BASE_PATH" | sed 's#/*$#/#; s#^/*#/#')
INDEX="/usr/share/nginx/html/index.html"
# Inject <base> tag after <head> and rewrite absolute asset paths
sed -i "s|<head>|<head><base href=\"${BASE_PATH}\">|" "$INDEX"
sed -i "s|href=\"/|href=\"${BASE_PATH}|g; s|src=\"/|src=\"${BASE_PATH}|g" "$INDEX"
echo "BASE_PATH set to ${BASE_PATH}rewrote index.html"
echo "BASE_PATH set to ${BASE_PATH}injected <base> tag into index.html"
fi
# Delegate to the default nginx entrypoint (handles envsubst for nginx templates)