Grapevine_Disease_Detection/vineye-admin/middleware.ts
Yanis fe70005a86 add vineye-admin dashboard (Next.js)
Admin panel for VinEye with dashboard, users, diseases, guides, alerts management.
Stack: Next.js App Router + Prisma + PostgreSQL + better-auth.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 11:22:01 +02:00

31 lines
733 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
export async function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
if (
pathname.startsWith("/dashboard") ||
pathname.startsWith("/diseases") ||
pathname.startsWith("/guides") ||
pathname.startsWith("/users") ||
pathname.startsWith("/alerts")
) {
const sessionCookie = request.cookies.get("better-auth.session_token");
if (!sessionCookie) {
return NextResponse.redirect(new URL("/login", request.url));
}
}
return NextResponse.next();
}
export const config = {
matcher: [
"/dashboard/:path*",
"/diseases/:path*",
"/guides/:path*",
"/users/:path*",
"/alerts/:path*",
],
};