From 165a1e0c408dcacbf9431bb114eab9838cdbb0b3 Mon Sep 17 00:00:00 2001 From: Bram Adams <3282661+bramses@users.noreply.github.com> Date: Fri, 23 Aug 2024 13:21:18 -0400 Subject: [PATCH] chore: Add error handling for unauthorized requests in getCBPath route --- src/app/[locale]/(auth)/api/getCBPath/route.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/[locale]/(auth)/api/getCBPath/route.ts b/src/app/[locale]/(auth)/api/getCBPath/route.ts index 472e4db..ba00c05 100644 --- a/src/app/[locale]/(auth)/api/getCBPath/route.ts +++ b/src/app/[locale]/(auth)/api/getCBPath/route.ts @@ -7,11 +7,11 @@ const cache = new NodeCache({ stdTTL: 600 }); // Cache for 10 minutes export async function GET(_: Request) { const { userId }: { userId: string | null } = auth(); - if (!userId) return null; + if (!userId) + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); const cachedData = cache.get(userId); if (cachedData) { - console.log('Returning cached data'); return NextResponse.json(cachedData); }