File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -2,21 +2,15 @@ import { cookies } from "next/headers";
2
2
import { NextRequest , NextResponse } from "next/server" ;
3
3
import { CookieNames } from "@/app/actions/session" ;
4
4
5
- const protectedRoutes = [ / ^ \/ q u e s t i o n s \/ / , / ^ \/ u s e r \/ / ] ;
6
- const publicRoutes = [ / ^ \/ $ / , / ^ \/ a u t h \/ l o g i n \/ $ / , / ^ \/ a u t h \/ r e g i s t e r \/ $ / ] ;
5
+ const protectedRoutes = [ "/questions" , "/user" ] ;
7
6
8
7
const isValidSession = ( ) => {
9
8
return cookies ( ) . has ( "session" ) ;
10
9
} ;
11
10
12
11
export async function middleware ( request : NextRequest ) {
13
12
const path = request . nextUrl . pathname ;
14
- const isProtectedRoute = protectedRoutes . some ( ( route ) => route . test ( path ) ) ;
15
- const isPublicRoute = publicRoutes . some ( ( route ) => route . test ( path ) ) ;
16
-
17
- if ( isPublicRoute ) {
18
- return NextResponse . next ( ) ;
19
- }
13
+ const isProtectedRoute = protectedRoutes . some ( ( route ) => path . startsWith ( route ) ) ;
20
14
21
15
// UNCOMMENT AND ADD TO ENV IF JUST TESTING FRONTEND STUFF
22
16
if ( process . env . NEXT_BYPASS_LOGIN === "yesplease" ) {
You can’t perform that action at this time.
0 commit comments