Skip to content

Commit

Permalink
fix(dashboard): add maintenance in middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
lindesvard committed Feb 17, 2025
1 parent 14468a1 commit 16b6786
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions apps/dashboard/src/app/maintenance/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 9 additions & 0 deletions apps/dashboard/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 16b6786

Please sign in to comment.