From fe283674fb4862c7be741e22b4101b994686103c Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Mon, 13 Apr 2026 21:30:00 +0200 Subject: [PATCH] fix: use relative asset paths with always-injected tag Switch Vite base back to './' (relative paths) and always inject in the entrypoint, even when BASE_PATH=/. This fixes asset loading for both deployment modes: - Single-instance: resolves ./assets/x.js to /assets/x.js - SaaS tenant: resolves to /t/slug/assets/x.js Previously base:'/' produced absolute /assets/ paths that the tag couldn't redirect, breaking SaaS tenants. And base:'./' without 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) --- ui/docker-entrypoint.sh | 22 ++++++++++------------ ui/vite.config.ts | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/ui/docker-entrypoint.sh b/ui/docker-entrypoint.sh index ef7cd46d..603ce30c 100644 --- a/ui/docker-entrypoint.sh +++ b/ui/docker-entrypoint.sh @@ -1,21 +1,19 @@ #!/bin/sh -# Inject 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 tag -# is sufficient — no asset path rewriting needed. -# Default: / (standalone mode, no tag needed). +# Inject 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 is the only +# mechanism needed — no sed rewriting of asset paths required. +# Default: / (standalone mode). BASE_PATH="${BASE_PATH:-/}" -if [ "$BASE_PATH" != "/" ]; then - # Ensure BASE_PATH starts and ends with / - BASE_PATH=$(echo "$BASE_PATH" | sed 's#/*$#/#; s#^/*#/#') +# 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|||" "$INDEX" +INDEX="/usr/share/nginx/html/index.html" +sed -i "s|||" "$INDEX" - echo "BASE_PATH set to ${BASE_PATH} — injected tag into index.html" -fi +echo "BASE_PATH set to ${BASE_PATH} — injected tag into index.html" # Delegate to the default nginx entrypoint (handles envsubst for nginx templates) exec /docker-entrypoint.sh "$@" diff --git a/ui/vite.config.ts b/ui/vite.config.ts index af041a4d..b4e74e8d 100644 --- a/ui/vite.config.ts +++ b/ui/vite.config.ts @@ -27,7 +27,7 @@ export default defineConfig({ optimizeDeps: { include: ['swagger-ui-dist/swagger-ui-bundle'], }, - base: '/', + base: './', build: { outDir: 'dist', },