Skip to content

Commit 9fbda59

Browse files
committed
middleware fix
1 parent 00c991e commit 9fbda59

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

utils/supabase/middleware.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ 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 !== '/') {
50+
if (
51+
!user && (request.nextUrl.pathname.startsWith('/dashboard'))
52+
) {
53+
// no user, potentially respond by redirecting the user to the login page
5254
const url = request.nextUrl.clone()
5355
url.pathname = '/auth/signin'
5456
return NextResponse.redirect(url)

0 commit comments

Comments
 (0)