import { withAuth } from "next-auth/middleware"; export default withAuth({ callbacks: { authorized: ({ token, req }) => { if (req.nextUrl.pathname.startsWith("/admin")) { return token?.role === "ADMIN"; } return token != null; }, }, }); export const config = { matcher: ["/dashboard/:path*", "/admin/:path*"], };