Files
football-next/proxy.ts
a.alinaghipour aa9ed69dd2 first commit
2026-04-05 15:53:20 +03:30

22 lines
526 B
TypeScript

import { withAuth } from "next-auth/middleware";
import { NextResponse } from "next/server";
export default withAuth(
function middleware(req) {
const token = req.nextauth.token;
const isAdminRoute = req.nextUrl.pathname.startsWith("/admin");
if (isAdminRoute && token?.role !== "ADMIN") {
return NextResponse.redirect(new URL("/", req.url));
}
},
{
callbacks: {
authorized: ({ token }) => !!token,
},
}
);
export const config = {
matcher: ["/admin/:path*", "/team/:path*"],
};