fix: redirect /auth/register to /auth/login when registration is disabled
This commit is contained in:
parent
cf2a980dd8
commit
472ef851c2
1 changed files with 8 additions and 1 deletions
|
|
@ -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+).*)',
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue