Files
padmaja/proxy.ts
2026-03-10 20:30:30 +05:30

27 lines
649 B
TypeScript

import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function proxy(request: NextRequest) {
const isSuspended = process.env.SITE_SUSPENDED === 'true'
// Fast path: do nothing if the site is not suspended.
if (!isSuspended) {
return NextResponse.next()
}
const { pathname } = request.nextUrl
// Allow access to the suspended page itself.
if (pathname === '/suspended') {
return NextResponse.next()
}
return NextResponse.redirect(new URL('/suspended', request.url))
}
export const config = {
matcher: [
'/((?!_next/static|_next/image|favicon.ico|suspended).*)',
],
}