From c4c43593e62940c63cadb2501a32baa0bc8652d4 Mon Sep 17 00:00:00 2001 From: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:03:23 +0000 Subject: [PATCH] fallback for /api/v1/config/endpoints-availability (#5842) --- .../src/desktop/hooks/useEndpointConfig.ts | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/frontend/src/desktop/hooks/useEndpointConfig.ts b/frontend/src/desktop/hooks/useEndpointConfig.ts index ad140dd4a..de4a504f1 100644 --- a/frontend/src/desktop/hooks/useEndpointConfig.ts +++ b/frontend/src/desktop/hooks/useEndpointConfig.ts @@ -215,12 +215,28 @@ export function useMultipleEndpointsEnabled(endpoints: string[]): { try { setError(null); - const response = await apiClient.get>( - `/api/v1/config/endpoints-availability`, - { - suppressErrorToast: true, + // Try new API first (no params — new servers return all endpoints). + // Fall back to the old ?endpoints= form for servers that predate the + // "large query reduction" change and still require the parameter. + let response: Awaited>>>; + try { + response = await apiClient.get>( + `/api/v1/config/endpoints-availability`, + { suppressErrorToast: true } + ); + } catch (innerErr) { + if (isAxiosError(innerErr) && innerErr.response?.status === 400) { + // Old server — requires explicit endpoints query param + console.debug('[useMultipleEndpointsEnabled] Server requires endpoints param, retrying with legacy format'); + const endpointsParam = endpoints.join(','); + response = await apiClient.get>( + `/api/v1/config/endpoints-availability?endpoints=${encodeURIComponent(endpointsParam)}`, + { suppressErrorToast: true } + ); + } else { + throw innerErr; } - ); + } const details = Object.entries(response.data).reduce((acc, [endpointName, detail]) => { acc[endpointName] = {