this repo has no description
at main 20 lines 597 B view raw
1import { headers } from "next/headers"; 2import { type NextRequest, NextResponse } from "next/server"; 3import { auth } from "@/lib/auth"; 4 5export async function proxy(request: NextRequest) { 6 const session = await auth.api.getSession({ 7 headers: await headers(), 8 }); 9 10 if (session) return NextResponse.next(); 11 12 const authUrl = new URL("/auth", request.url); 13 const next = request.nextUrl.href.replace(request.nextUrl.origin, ""); 14 authUrl.searchParams.set("next", next); 15 return NextResponse.redirect(authUrl); 16} 17 18export const config = { 19 matcher: ["/", "/settings", "/:id(\\d+)"], 20};