fix: make API calls respect BASE_PATH for subpath deployments
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m7s
CI / docker (push) Successful in 57s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 37s

config.apiBaseUrl now derives from <base> tag when no explicit config
is set (e.g., /server/api/v1 instead of /api/v1). commands.ts authFetch
prepends apiBaseUrl and uses relative paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-06 00:04:52 +02:00
parent 5b7c92848d
commit 7ebbc18b31
2 changed files with 19 additions and 12 deletions

View File

@@ -6,8 +6,14 @@ declare global {
}
}
/** Base path from <base href="..."> tag, or '/' if none. Always ends with '/'. */
const basePath = document.querySelector('base')?.getAttribute('href') ?? '/';
export const config = {
get apiBaseUrl(): string {
return window.__CAMELEER_CONFIG__?.apiBaseUrl ?? '/api/v1';
return window.__CAMELEER_CONFIG__?.apiBaseUrl ?? `${basePath}api/v1`;
},
get basePath(): string {
return basePath;
},
};