From 472ef851c24b7825b682f1eee75bef20091f0eb2 Mon Sep 17 00:00:00 2001 From: swaraj017 Date: Wed, 18 Mar 2026 12:45:43 +0530 Subject: [PATCH] fix: redirect /auth/register to /auth/login when registration is disabled --- apps/frontend/src/middleware.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/frontend/src/middleware.ts b/apps/frontend/src/middleware.ts index 6152560b..fe9059de 100644 --- a/apps/frontend/src/middleware.ts +++ b/apps/frontend/src/middleware.ts @@ -70,6 +70,13 @@ export async function middleware(request: NextRequest) { return response; } + if ( + nextUrl.pathname.startsWith('/auth/register') && + process.env.NEXT_PUBLIC_DISABLE_REGISTRATION === 'true' + ) { + return NextResponse.redirect(new URL('/auth/login', nextUrl.href)); + } + const org = nextUrl.searchParams.get('org'); const url = new URL(nextUrl).search; if (!nextUrl.pathname.startsWith('/auth') && !authCookie) { @@ -160,4 +167,4 @@ export async function middleware(request: NextRequest) { // See "Matching Paths" below to learn more export const config = { matcher: '/((?!api/|_next/|_static/|_vercel|[\\w-]+\\.\\w+).*)', -}; +}; \ No newline at end of file