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>
22 lines
783 B
Bash
22 lines
783 B
Bash
#!/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:-/}"
|
|
|
|
if [ "$BASE_PATH" != "/" ]; then
|
|
# Ensure BASE_PATH starts and ends with /
|
|
BASE_PATH=$(echo "$BASE_PATH" | sed 's#/*$#/#; s#^/*#/#')
|
|
|
|
INDEX="/usr/share/nginx/html/index.html"
|
|
sed -i "s|<head>|<head><base href=\"${BASE_PATH}\">|" "$INDEX"
|
|
|
|
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)
|
|
exec /docker-entrypoint.sh "$@"
|