/admin and with working with db. data is pulling from db

This commit is contained in:
2025-06-30 20:26:00 -04:00
parent 5c046874a8
commit b478d9797d
33 changed files with 1214 additions and 58 deletions

16
middleware.ts Normal file
View File

@@ -0,0 +1,16 @@
import { NextResponse, NextRequest } from 'next/server';
import { getToken } from 'next-auth/jwt';
export async function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/admin')) {
const token = await getToken({ req: request, secret: process.env.NEXTAUTH_SECRET });
if (!token || !token.isAdmin) {
return NextResponse.redirect(new URL('/account/login', request.url));
}
}
return NextResponse.next();
}
export const config = {
matcher: ['/admin/:path*'],
};