Skip to content

Commit e287d01

Browse files
committed
middleware fix
1 parent 63a4477 commit e287d01

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

utils/supabase/middleware.ts

+9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ export async function updateSession(request: NextRequest) {
4747
// return NextResponse.redirect(url)
4848
// }
4949

50+
//if no user and user try to hit any route other than /auth/signin or /auth/signup or /, redirect to /auth/signin
51+
if (!user && !request.nextUrl.pathname.startsWith('/auth/signin') && !request.nextUrl.pathname.startsWith('/auth/signup') && request.nextUrl.pathname !== '/') {
52+
const url = request.nextUrl.clone()
53+
url.pathname = '/auth/signin'
54+
return NextResponse.redirect(url)
55+
}
56+
57+
58+
5059
if (
5160
user &&
5261
(request.nextUrl.pathname === '/' ||

0 commit comments

Comments
 (0)