import { getServerSession } from "next-auth"; import { authOptions } from "@/lib/auth"; import { NextResponse } from "next/server"; /** * Verify that the user is authenticated * Returns null if authenticated, or a NextResponse with 401 if not */ export async function requireAuth(): Promise { const session = await getServerSession(authOptions); if (!session) { return NextResponse.json( { error: "Non authentifié" }, { status: 401 } ); } return null; }