瀏覽代碼

test for prod fix

simo 2 天之前
父節點
當前提交
524af82fb0
共有 1 個文件被更改,包括 7 次插入2 次删除
  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, {