Parcourir la source

test for prod fix

simo il y a 2 jours
Parent
commit
524af82fb0
1 fichiers modifiés avec 7 ajouts et 2 suppressions
  1. 7 2
      src/pages/api/game/[id]/index.ts

+ 7 - 2
src/pages/api/game/[id]/index.ts

@@ -14,12 +14,17 @@ export const POST: APIRoute = async ({ request, params }) => {
   await init();
 
   const currentUser = getUserFromRequest(request);
+
+  console.log(request.headers.get("cookie"));
+  console.log(currentUser);
   if (!currentUser) return json({ error: "Not authenticated" }, 401);
 
   const game = await getGame(params.id!);
   if (!game) return json({ error: "Not found" }, 404);
-  if (game.status !== "waiting") return json({ error: "Game already started" }, 400);
-  if (game.player1 === currentUser) return json({ error: "You are already player 1" }, 400);
+  if (game.status !== "waiting")
+    return json({ error: "Game already started" }, 400);
+  if (game.player1 === currentUser)
+    return json({ error: "You are already player 1" }, 400);
   if (game.player2) return json({ error: "Game is full" }, 400);
 
   const updated = await updateGame(game.id, {