Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/pages/api/game/submit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions src/pages/game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading