diff --git a/src/app/route.ts b/src/app/route.ts index 2594f57c..778f1a41 100644 --- a/src/app/route.ts +++ b/src/app/route.ts @@ -4,12 +4,6 @@ import { NextResponse } from 'next/server'; export const dynamic = 'force-dynamic'; export async function GET() { - if (process.env.NEXT_PUBLIC_SSO_DOMAIN !== undefined) { - return NextResponse.redirect( - new URL('/auth/sso-verify', process.env.NEXT_PUBLIC_SITE_URL), - ); - } - const supabase = createSupabaseUserRouteHandlerClient(); const { diff --git a/src/middleware.ts b/src/middleware.ts index 6c40dab3..2dee6f8d 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -78,8 +78,11 @@ export async function middleware(req: NextRequest) { { supabaseUrl: process.env.NEXT_PUBLIC_SUPABASE_URL }, ); - if (req.nextUrl.pathname === '/') { - return res; + if ( + process.env.NEXT_PUBLIC_SSO_DOMAIN !== undefined && + req.nextUrl.pathname === '/' + ) { + return NextResponse.redirect(toSiteURL('/auth/sso-verify')); } const sessionResponse = await supabase.auth.getSession();