From f44fadb77dd3eb57b268d21d766abde3d47b3cb6 Mon Sep 17 00:00:00 2001 From: Manav Kohli Date: Thu, 20 Aug 2026 01:02:02 +0530 Subject: [PATCH] immediate fix --- src/pages/api/game/submit.ts | 5 ++--- src/pages/game/index.tsx | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/api/game/submit.ts b/src/pages/api/game/submit.ts index dfe3cb9..c752ae1 100644 --- a/src/pages/api/game/submit.ts +++ b/src/pages/api/game/submit.ts @@ -30,9 +30,8 @@ export default async function handler( .update(payloadString) .digest("hex"); - // Fire-and-forget: we send the payload to Google Apps Script in the background - // and immediately return a 200 OK so the user is never blocked. - fetch(scriptUrl, { + // Await the fetch to ensure Vercel doesn't kill the lambda before the network request completes + await fetch(scriptUrl, { method: "POST", redirect: "follow", headers: { diff --git a/src/pages/game/index.tsx b/src/pages/game/index.tsx index 2823f59..c6ce34b 100644 --- a/src/pages/game/index.tsx +++ b/src/pages/game/index.tsx @@ -68,6 +68,7 @@ export default function GamePage() { const localPlayed = localStorage.getItem("hasPlayedDinoGame"); if (localPlayed && process.env.NODE_ENV !== "development") { setAlreadyPlayed(true); + await fetchLeaderboardData(currentDeviceId); // Must fetch so they can actually see the leaderboard! setIsLoading(false); return; }