import { queryOne } from "@/lib/db"; import { getToken } from "next-auth/jwt"; export const dynamic = "force-dynamic"; // No caching export async function GET(request) { try { // Verify token const token = await getToken({ req: request, secret: process.env.NEXTAUTH_SECRET || "your-fallback-secret-should-be-at-least-32-chars", }); if (!token) { return Response.json({ error: "Unauthorized access" }, { status: 401 }); } // Get the total count of clues const result = await queryOne("SELECT COUNT(*) as count FROM clues"); if (!result) { return Response.json({ error: "Failed to count clues" }, { status: 500 }); } return Response.json( { count: result.count }, { headers: { "Cache-Control": "no-store, no-cache, must-revalidate", Pragma: "no-cache", }, } ); } catch (error) { console.error("Error counting clues:", error); return Response.json({ error: "Server error" }, { status: 500 }); } }