import { NextRequest, NextResponse } from "next/server"; export function middleware(request: NextRequest) { const session = request.cookies.get("drb_session"); const { pathname } = request.nextUrl; if (pathname === "/login") { if (session) return NextResponse.redirect(new URL("/dashboard", request.url)); return NextResponse.next(); } if (!session) { return NextResponse.redirect(new URL("/login", request.url)); } return NextResponse.next(); } export const config = { matcher: ["/((?!_next/static|_next/image|favicon\\.ico).*)"], };