How to create different middleware for route groups? #62970
-
Beta Was this translation helpful? Give feedback.
Answered by
AmrViernes
May 15, 2024
Replies: 2 comments 2 replies
-
How to make middleware work only for This is my import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
const isLoggedIn = checkUserLoggedIn(request);
if (!isLoggedIn) {
return NextResponse.redirect(new URL('/login', request.url));
}
return NextResponse.next();
}
function checkUserLoggedIn(request: NextRequest): boolean {
return false;
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
you need to chain middlewares this video gonna solve your problem |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
HaceraI
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you need to chain middlewares this video gonna solve your problem
https://www.youtube.com/watch?v=fmFYH_Xu3d0&ab_channel=HamedBahram