diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 511bb338..b72467d5 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -135,6 +135,12 @@ fi echo "Starting nginx..." nginx -c /tmp/nginx/nginx.conf +# Inject runtime BASE_PATH into frontend if configured +if [ -n "$BASE_PATH" ]; then + echo "Injecting BASE_PATH: $BASE_PATH" + find /app/html -name "index.html" -exec sed -i "s|window.__TERMIX_BASE_PATH__ = \"\"|window.__TERMIX_BASE_PATH__ = \"$BASE_PATH\"|g" {} \; +fi + echo "Starting backend services..." cd /app export NODE_ENV=production diff --git a/index.html b/index.html index c3d2bf08..f774a2b1 100644 --- a/index.html +++ b/index.html @@ -47,6 +47,7 @@ +
diff --git a/src/ui/lib/base-path.ts b/src/ui/lib/base-path.ts index 0352e12c..a06aad52 100644 --- a/src/ui/lib/base-path.ts +++ b/src/ui/lib/base-path.ts @@ -1,4 +1,9 @@ export function getBasePath(): string { + const runtime = (window as unknown as Record) + .__TERMIX_BASE_PATH__ as string | undefined; + if (runtime) { + return runtime.endsWith("/") ? runtime.slice(0, -1) : runtime; + } const base = import.meta.env.BASE_URL || "/"; if (base === "./" || base === "/") return ""; return base.endsWith("/") ? base.slice(0, -1) : base;