From 2cfcc60b65c667ebc6bdfed32476ace446869c60 Mon Sep 17 00:00:00 2001 From: alma Date: Fri, 16 Jan 2026 23:28:58 +0100 Subject: [PATCH] Fondation --- app/api/courrier/route.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/api/courrier/route.ts b/app/api/courrier/route.ts index e11613b..32a41b3 100644 --- a/app/api/courrier/route.ts +++ b/app/api/courrier/route.ts @@ -23,15 +23,16 @@ const CACHE_TTL = 60 * 1000; const emailListCache: Record = {}; export async function GET(request: Request) { + // Authenticate user (declare outside try to access in catch) + const session = await getServerSession(authOptions); + if (!session || !session.user?.id) { + return NextResponse.json( + { error: "Not authenticated" }, + { status: 401 } + ); + } + try { - // Authenticate user - const session = await getServerSession(authOptions); - if (!session || !session.user?.id) { - return NextResponse.json( - { error: "Not authenticated" }, - { status: 401 } - ); - } // Extract query parameters const { searchParams } = new URL(request.url);