This commit is contained in:
Timothy Jaeryang Baek
2026-03-24 05:21:42 -05:00
parent 69171a4c8b
commit 24370d5c40
2 changed files with 32 additions and 0 deletions
+26
View File
@@ -1406,6 +1406,32 @@ export const getBackendConfig = async () => {
});
if (error) {
// When a forward-auth proxy (e.g. Authentik/Traefik) intercepts the
// request and redirects to an external login page, the browser blocks
// the cross-origin redirect for fetch() and throws a TypeError.
// Detect this by re-fetching with redirect:"manual" — if the server
// responded with a redirect, the probe returns an opaque redirect
// response instead of throwing, confirming the backend is alive but
// an auth proxy is intercepting.
if (error instanceof TypeError) {
try {
const probeRes = await fetch(`${WEBUI_BASE_URL}/api/config`, {
method: 'GET',
credentials: 'include',
redirect: 'manual',
headers: { 'Content-Type': 'application/json' }
});
if (
probeRes.type === 'opaqueredirect' ||
(probeRes.status >= 300 && probeRes.status < 400)
) {
throw { authRedirect: true };
}
} catch (probeErr: any) {
if (probeErr?.authRedirect) throw probeErr;
// Probe also failed — genuine network/backend issue
}
}
throw error;
}
+6
View File
@@ -906,6 +906,12 @@
backendConfig = await getBackendConfig();
console.log('Backend config:', backendConfig);
} catch (error) {
if (error?.authRedirect) {
// Forward-auth proxy is redirecting to an external login page.
// Full-page navigation lets the browser follow the redirect natively.
window.location.href = '/';
return;
}
console.error('Error loading backend config:', error);
}
// Initialize i18n even if we didn't get a backend config,