Skip to content

Commit

Permalink
chore: Add error handling for unauthorized requests in getCBPath route
Browse files Browse the repository at this point in the history
  • Loading branch information
bramses committed Aug 23, 2024
1 parent 5b20b1f commit 165a1e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/app/[locale]/(auth)/api/getCBPath/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 165a1e0

Please sign in to comment.