fix: redirect /auth/register to /auth/login when registration is disabled

This commit is contained in:
swaraj017 2026-03-18 12:45:43 +05:30
parent cf2a980dd8
commit 472ef851c2

View file

@ -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+).*)',
};
};