This repository was archived by the owner on Mar 13, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import { Score } from '@/app/models/Score';
55
66// Ensure Node.js runtime (not Edge) so we can use Mongoose
77export const runtime = 'nodejs' ;
8+ // Force dynamic to prevent aggressive caching
9+ export const dynamic = 'force-dynamic' ;
810
911// Reuse a cached connection across hot reloads / lambda invocations to avoid creating many sockets.
1012declare global {
@@ -27,6 +29,7 @@ async function connectToDatabase(uri: string) {
2729// Handle POST request to save a score
2830export async function POST ( req : Request ) {
2931 const DB_URI = process . env . MONGO_URI ; // read at request time to avoid build-time inlining issues
32+ console . log ( 'POST /api/scores - MONGO_URI present:' , ! ! DB_URI , 'length:' , DB_URI ?. length || 0 ) ;
3033 if ( ! DB_URI ) {
3134 return NextResponse . json ( { error : 'Server not configured (MONGO_URI missing)' } , { status : 503 } ) ;
3235 }
@@ -51,6 +54,7 @@ export async function POST(req: Request) {
5154// Handle GET request to fetch all scores
5255export async function GET ( ) {
5356 const DB_URI = process . env . MONGO_URI ; // read at request time
57+ console . log ( 'GET /api/scores - MONGO_URI present:' , ! ! DB_URI , 'length:' , DB_URI ?. length || 0 ) ;
5458 if ( ! DB_URI ) {
5559 return NextResponse . json ( { error : 'Server not configured (MONGO_URI missing)' } , { status : 503 } ) ;
5660 }
You can’t perform that action at this time.
0 commit comments