WeKnora/frontend/src/utils/api-base.ts

10 lines
495 B
TypeScript

export function getApiBaseUrl(): string {
// LocalHub plugin patch (2026-04-29): respect vite's BASE_URL so that
// axios calls work at `/app/weknora/` (LocalHub reverse proxy). Without
// this · axios hits `/api/v1/...` at LocalHub root · gets 404 "Cannot
// POST". Strip trailing slash so axios doesn't produce `/app/weknora//api/v1/...`.
// See: plugins/weknora/patches/api-base-baseurl.patch
const base = (import.meta.env.BASE_URL || '/').replace(/\/+$/, '');
return base;
}