fix(frontend): Interceptor normalisiert ALLE apiClient-URLs — auch Direktaufrufe und Cache-Alte-Chunks

Der apiX-Wrapper-Fix (744f2a1) heilte nur Wrapper-Aufrufe. Produktion-Logs
zeigten: POST /api/v1/api/v1/ai-proactive/context → 405 (4x vom User-
Browser mit alten gecachten Chunks). Der Request-Interceptor strippt jetzt
redundante /api/v1-Präfixe auf Transport-Ebene — heilt auch Direkt-
apiClient-Calls und stale Cache-Artefakte transparent.
This commit is contained in:
Agent Zero
2026-09-12 00:32:42 +02:00
parent ac5edef3dc
commit 86cea5d6c4
+10
View File
@@ -47,6 +47,16 @@ export function setValidationErrorHandler(handler: (errors: Record<string, strin
apiClient.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// 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) {