import { NextResponse } from "next/server"; import type { NextRequest } from "next/server"; const SESSION_COOKIE = "refreshToken"; export function proxy(request: NextRequest) { const hasSession = request.cookies.has(SESSION_COOKIE); const { pathname } = request.nextUrl; if (pathname.startsWith("/login")) { if (hasSession) { return NextResponse.redirect(new URL("/settings/users", request.url)); } return NextResponse.next(); } if (!hasSession) { return NextResponse.redirect(new URL("/login", request.url)); } return NextResponse.next(); } export const config = { matcher: ["/login", "/settings/:path*", "/apiaries/:path*"], };