diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index ae5515f..bff62c0 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -47,6 +47,16 @@ export function setValidationErrorHandler(handler: (errors: Record { + // Normalize URLs: strip a redundant leading '/api/v1' when it collides + // with the axios baseURL '/api/v1' (double-prefix → 404/405). Done here + // in the interceptor (not only in the apiX wrappers) so DIRECT apiClient + // calls are covered too — stale browser-cache chunks keep calling with + // full prefixes after deploys and this heals them transparently. + if (typeof config.url === 'string' && config.url.startsWith('/api/v1/')) { + config.url = config.url.slice('/api/v1'.length); + } else if (config.url === '/api/v1') { + config.url = '/'; + } // Attach CSRF token on unsafe methods const unsafe = ['post', 'put', 'patch', 'delete']; if (unsafe.includes(config.method?.toLowerCase() ?? '') && csrfToken) {