Changes back-end unavailable to redirect to login instead of setup page

This commit is contained in:
2026-06-23 22:13:01 +02:00
parent 2544e20b3c
commit b84e2f8e3e
4 changed files with 33 additions and 7 deletions
+8 -5
View File
@@ -8,7 +8,7 @@ import {
} from '@tanstack/react-router';
import type { AuthContextValue } from '@/contexts/auth-context';
import type { SetupStatus } from '@/api/types';
import { api } from '@/lib/api-client';
import { api, NetworkError } from '@/lib/api-client';
import { AppLayout } from '@/components/layout/AppLayout';
import { LoginPage } from '@/pages/LoginPage';
import { NotFoundPage } from '@/pages/NotFoundPage';
@@ -99,10 +99,13 @@ const rootRoute = createRootRouteWithContext<RouterContext>()({
try {
status = await fetchSetupStatus();
} catch (err) {
// On network failure, assume not initialized so the user can set up
// the system once the backend is reachable. Logging helps debugging.
console.warn('[InitGuard] Setup status check failed, assuming not initialized:', err);
status = { initialized: false };
if (err instanceof NetworkError) {
// Backend unreachable: skip setup redirect and show the login page instead.
status = { initialized: true };
} else {
console.warn('[InitGuard] Setup status check failed, assuming not initialized:', err);
status = { initialized: false };
}
}
const onSetup = location.pathname === '/setup';