Merge pull request #1326 from swaraj017/fix/redirect-register-to-login

fix: redirect /auth/register to /auth/login when registration is disabled
This commit is contained in:
Enno Gelhaus 2026-03-20 16:27:10 +01:00 committed by GitHub
commit 2cd2911de2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -70,6 +70,13 @@ export async function middleware(request: NextRequest) {
return response;
}
if (
nextUrl.pathname.startsWith('/auth/register') &&
process.env.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+).*)',
};
};