fix(dashboard): add maintenance in middleware

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-02-17 06:02:15 +01:00
parent 14468a1004
commit 16b6786165
2 changed files with 13 additions and 4 deletions

View File

@@ -3,13 +3,13 @@ import { CalendarCogIcon } from 'lucide-react';
export default function Maintenance() {
return (
<div className="h-screen w-full center-center overflow-hidden">
<div className="relative z-10 col gap-2 center-center">
<div className="relative z-10 col gap-2 center-center p-4">
<CalendarCogIcon className="size-32 mb-4 animate-wiggle text-def-300" />
<div className="text-[150px] font-mono font-bold -mb-16 leading-[1] select-none pointer-events-none whitespace-nowrap bg-gradient-to-b from-def-300 to-def-100 bg-clip-text text-transparent">
<div className="text-[90px] sm:text-[150px] font-mono font-bold -mb-16 leading-[1] select-none pointer-events-none whitespace-nowrap bg-gradient-to-b from-def-300 to-def-100 bg-clip-text text-transparent">
Oh no!
</div>
<h1 className="text-6xl font-bold">Maintenance</h1>
<p className="text-xl text-muted-foreground">
<h1 className="text-5xl sm:text-6xl font-bold">Maintenance</h1>
<p className="text-xl text-muted-foreground leading-normal">
We&apos;re doing a planned maintenance. Please check back later.
</p>
</div>

View File

@@ -28,9 +28,18 @@ const isPublicRoute = createRouteMatcher([
'/reset-password(.*)?',
'/sso-callback(.*)?',
'/onboarding',
'/maintenance',
]);
export default (request: NextRequest) => {
// Check for maintenance mode
if (
process.env.MAINTENANCE === 'true' &&
!request.nextUrl.pathname.startsWith('/maintenance')
) {
return NextResponse.redirect(new URL('/maintenance', request.url));
}
if (request.method === 'GET') {
const response = NextResponse.next();
const token = request.cookies.get('session')?.value ?? null;