Changes back-end unavailable to redirect to login instead of setup page
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user