From 50c2c17c5b4bc9d1d056ff6dcdd08f6a9997ae11 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 5 Feb 2026 21:20:30 +0530 Subject: [PATCH] add maintenance mode --- ui/.env.example | 4 ++++ ui/src/app/maintenance/page.tsx | 17 +++++++++++++++++ ui/src/middleware.ts | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 ui/src/app/maintenance/page.tsx diff --git a/ui/.env.example b/ui/.env.example index 284108b..ba252aa 100644 --- a/ui/.env.example +++ b/ui/.env.example @@ -4,3 +4,7 @@ BACKEND_URL=http://localhost:8000 NEXT_PUBLIC_NODE_ENV=development NEXT_PUBLIC_DEPLOYMENT_MODE: "oss" NEXT_PUBLIC_AUTH_PROVIDER="local" + +# Maintenance Mode +# MAINTENANCE_MODE=true +# MAINTENANCE_MESSAGE="We are currently performing scheduled maintenance. Please check back soon." diff --git a/ui/src/app/maintenance/page.tsx b/ui/src/app/maintenance/page.tsx new file mode 100644 index 0000000..a53e8dd --- /dev/null +++ b/ui/src/app/maintenance/page.tsx @@ -0,0 +1,17 @@ +export default function MaintenancePage() { + const message = + process.env.MAINTENANCE_MESSAGE || + 'We are currently performing scheduled maintenance. Please check back soon.'; + + return ( +
+
+
🔧
+

+ Under Maintenance +

+

{message}

+
+
+ ); +} diff --git a/ui/src/middleware.ts b/ui/src/middleware.ts index 1edfb5e..b184353 100644 --- a/ui/src/middleware.ts +++ b/ui/src/middleware.ts @@ -9,6 +9,19 @@ function generateOSSToken(): string { } export function middleware(request: NextRequest) { + // Check for maintenance mode + const maintenanceMode = process.env.MAINTENANCE_MODE === 'true'; + + if (maintenanceMode) { + // Allow access to the maintenance page itself to avoid redirect loop + if (request.nextUrl.pathname === '/maintenance') { + return NextResponse.next(); + } + + // Redirect all other requests to maintenance page + return NextResponse.redirect(new URL('/maintenance', request.url)); + } + const authProvider = process.env.NEXT_PUBLIC_AUTH_PROVIDER || 'stack'; // Only handle OSS mode