import { headers } from "next/headers"; import { type NextRequest, NextResponse } from "next/server"; import { auth } from "@/lib/auth"; export async function proxy(request: NextRequest) { const session = await auth.api.getSession({ headers: await headers(), }); if (session) return NextResponse.next(); const authUrl = new URL("/auth", request.url); const next = request.nextUrl.href.replace(request.nextUrl.origin, ""); authUrl.searchParams.set("next", next); return NextResponse.redirect(authUrl); } export const config = { matcher: ["/", "/settings", "/:id(\\d+)"], };