diff --git a/src/middleware.ts b/src/middleware.ts index 4dff0c1..f719a28 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -17,6 +17,14 @@ export async function middleware(req: NextRequest) { return NextResponse.redirect(url); } + if ( + !token?.user.roles.includes("admin") && + url.pathname.startsWith("/admin") + ) { + url.pathname = "/"; + return NextResponse.redirect(url); + } + return NextResponse.next(); }