diff --git a/app/api/admin/daily-puzzles/route.ts b/app/api/admin/daily-puzzles/route.ts index 3985071..231d40c 100644 --- a/app/api/admin/daily-puzzles/route.ts +++ b/app/api/admin/daily-puzzles/route.ts @@ -42,7 +42,20 @@ export async function GET() { } })); - return NextResponse.json(formattedPuzzles); + // Filter out duplicates (keep only the first one per category) + // This matches the behavior of getOrCreateDailyPuzzle which uses findFirst + const uniquePuzzles = []; + const seenCategories = new Set(); + + for (const puzzle of formattedPuzzles) { + const key = `${puzzle.categoryType}-${puzzle.genreId || 'null'}-${puzzle.specialId || 'null'}`; + if (!seenCategories.has(key)) { + seenCategories.add(key); + uniquePuzzles.push(puzzle); + } + } + + return NextResponse.json(uniquePuzzles); } catch (error) { console.error('Error fetching daily puzzles:', error); return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });