Switch Vite base back to './' (relative paths) and always inject
<base href="${BASE_PATH}"> in the entrypoint, even when BASE_PATH=/.
This fixes asset loading for both deployment modes:
- Single-instance: <base href="/"> resolves ./assets/x.js to /assets/x.js
- SaaS tenant: <base href="/t/slug/"> resolves to /t/slug/assets/x.js
Previously base:'/' produced absolute /assets/ paths that the <base>
tag couldn't redirect, breaking SaaS tenants. And base:'./' without
<base> broke deep URLs in single-instance mode. Always injecting the
tag makes relative paths work universally.
The patched server-ui-entrypoint.sh in cameleer-saas (which rewrote
absolute href/src attributes via sed) is no longer needed and can be
removed.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
20 lines
754 B
Bash
20 lines
754 B
Bash
#!/bin/sh
|
|
# Inject <base> tag into index.html so relative asset paths (./assets/...)
|
|
# resolve correctly regardless of the browser URL depth or subpath mount.
|
|
# Vite builds with base: './' (relative paths), so <base> is the only
|
|
# mechanism needed — no sed rewriting of asset paths required.
|
|
# Default: / (standalone mode).
|
|
|
|
BASE_PATH="${BASE_PATH:-/}"
|
|
|
|
# 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"
|
|
|
|
# Delegate to the default nginx entrypoint (handles envsubst for nginx templates)
|
|
exec /docker-entrypoint.sh "$@"
|