add maintenance mode

This commit is contained in:
Abhishek Kumar 2026-02-05 21:20:30 +05:30
parent e8005042e2
commit 50c2c17c5b
3 changed files with 34 additions and 0 deletions

View file

@ -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."

View file

@ -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 (
<div className="flex min-h-screen flex-col items-center justify-center bg-background px-4">
<div className="max-w-md text-center">
<div className="mb-6 text-6xl">🔧</div>
<h1 className="mb-4 text-2xl font-bold text-foreground">
Under Maintenance
</h1>
<p className="text-muted-foreground">{message}</p>
</div>
</div>
);
}

View file

@ -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