veritas-kanban/web/src/lib/config.ts
Brad Groux f82741fde4
Some checks are pending
CI / Lint & Type Check (push) Waiting to run
CI / Workspace Unit Tests (push) Waiting to run
CI / Build (push) Waiting to run
CI / Security Audit (push) Waiting to run
Add local LLM agent providers (#695)
2026-06-06 15:26:12 -05:00

18 lines
617 B
TypeScript

/**
* Shared configuration for the application.
*
* When deployed under a sub-path (e.g., /kanban/), Vite sets
* import.meta.env.BASE_URL to that path. We derive API_BASE from it
* so all fetch calls hit the correct prefix automatically.
*/
const basePath = (import.meta.env.BASE_URL || '/').replace(/\/$/, '');
export function normalizeApiBase(rawBase: string): string {
const trimmed = rawBase.replace(/\/$/, '');
if (/^https?:\/\/[^/]+$/i.test(trimmed)) {
return `${trimmed}/api`;
}
return trimmed;
}
export const API_BASE = normalizeApiBase(import.meta.env.VITE_API_URL || `${basePath}/api`);