A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
fix: resolves frontend rate-limit error due to frequent pending setup check
towfiqi6194d4e2b508
diff --git a/backend/src/createApp.ts b/backend/src/createApp.tsindex 0f561ad..9cbc422 100644--- a/backend/src/createApp.ts+++ b/backend/src/createApp.ts@@ -131,7 +131,7 @@ export async function createApp(): Promise<{ app: Express }> {],credentials: true,methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],- exposedHeaders: ['X-App-Version', 'X-Server-OS'],+ exposedHeaders: ['X-App-Version', 'X-Server-OS', 'X-Install-Type', 'X-Setup-Pending'],}));app.use(versionMiddleware);diff --git a/backend/src/middlewares/versionMiddleware.ts b/backend/src/middlewares/versionMiddleware.tsindex 92c0139..2fcf3d6 100644--- a/backend/src/middlewares/versionMiddleware.ts+++ b/backend/src/middlewares/versionMiddleware.ts@@ -1,5 +1,6 @@import { Request, Response, NextFunction } from 'express';import { getInstallType } from '../utils/installHelpers';+import { configService } from '../services/ConfigService';// Read package.json once at startupconst appVersion: string = process.env.APP_VERSION || 'dev';@@ -9,8 +10,10 @@ const appVersion: string = process.env.APP_VERSION || 'dev';*/export default function versionMiddleware(req: Request, res: Response, next: NextFunction) {// Add version to response headers+ const isSetupPending = configService.isSetupPending();res.setHeader('X-App-Version', appVersion);res.setHeader('X-Server-OS', process.platform);res.setHeader('X-Install-Type', getInstallType());+ res.setHeader('X-Setup-Pending', isSetupPending ? 1 : 0);next();}diff --git a/frontend/src/router.tsx b/frontend/src/router.tsxindex f599aa7..43ca836 100644--- a/frontend/src/router.tsx+++ b/frontend/src/router.tsx@@ -3,7 +3,6 @@ import Plans from './routes/Plans/Plans';import Login from './routes/Login/Login';import Setup from './routes/Setup/Setup';import { useAuth } from './services/users';-import { useSetupStatus } from './services/settings';import App from './components/App/App/App';import Settings from './routes/Settings/Settings';import Storages from './routes/Storages/Storages';@@ -33,13 +32,9 @@ function PublicRoute({ children }: { children: React.ReactNode }) {}function ProtectedLayout() {- // Check setup status FIRST - this endpoint doesn't require auth- // and tells us if we're in binary mode and if setup is pending- const { data: setupStatus, isLoading: setupLoading } = useSetupStatus();const { data: authData, isError: authError, isLoading: authLoading } = useAuth();- // Show loading spinner while checking setup status- if (setupLoading) {+ if (authLoading) {return (<div className="loadingScreen"><Icon size={60} type="loading" />@@ -47,24 +42,13 @@ function ProtectedLayout() {);}- // If setup status check failed, we can still proceed with auth check- // (might be a network issue or old backend without setup endpoint)-- // For binary installations with pending setup, redirect to setup page- // This check happens BEFORE auth check so unauthenticated users can access setup- if (setupStatus?.data?.isBinary && setupStatus?.data?.setupPending) {+ // Check setup-pending from auth response headers (set by versionMiddleware on all responses)+ const installType = (window as any).plutonInstallType;+ const setupPending = (window as any).plutonSetupPending;+ if (installType === 'binary' && setupPending) {return <Navigate to="/setup" replace />;}- // Now check auth (setup is either complete or not a binary installation)- if (authLoading) {- return (- <div className="loadingScreen">- <Icon size={60} type="loading" />- </div>- );- }-// If auth failed, redirect to loginif (authError) {return <Navigate to="/login" replace />;diff --git a/frontend/src/services/users.ts b/frontend/src/services/users.tsindex 3cf2da1..a53932e 100644--- a/frontend/src/services/users.ts+++ b/frontend/src/services/users.ts@@ -12,22 +12,28 @@ export type InstallType = 'docker' | 'binary' | 'dev';//VALIDATE USERexport async function validateAuth() {const res = await fetch(`${API_URL}/user/validate`, { method: 'GET', credentials: 'include' });- if (!res.ok) {- throw new Error('Invalid authentication');- }++ // Read headers before checking status - middleware sets these on all responsesconst appVersion = res.headers.get('x-app-version');const serverOS = res.headers.get('x-server-os');const installType = (res.headers.get('x-install-type') || 'dev') as InstallType;+ const setupPending = res.headers.get('x-setup-pending') === '1';(window as any).plutonVersion = appVersion || 'unknown';(window as any).plutonServerOS = serverOS || 'unknown';(window as any).plutonInstallType = installType;+ (window as any).plutonSetupPending = setupPending;++ if (!res.ok) {+ throw new Error('Invalid authentication');+ }const data = await res.json();return {...data,appVersion,installType,+ setupPending,};}