From 3ec8bce7073bd922096681348fa86b6e8ff9b0d1 Mon Sep 17 00:00:00 2001 From: yyamashita Date: Sat, 20 Jun 2026 00:37:48 +0900 Subject: Debug: show raw response body to diagnose json() failure Co-Authored-By: Claude Sonnet 4.6 --- app/routes/auth.register.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/routes/auth.register.tsx b/app/routes/auth.register.tsx index 7d8fb5d..43e9c71 100644 --- a/app/routes/auth.register.tsx +++ b/app/routes/auth.register.tsx @@ -132,12 +132,18 @@ export default function Register() { body: JSON.stringify({ token }), }); setStep("1b. fetch 完了 status=" + optRes.status); await tick(); + const rawText = await optRes.text(); + setStep("1c. body=" + rawText.slice(0, 120)); await tick(); if (!optRes.ok) { - const err = await optRes.json(); - throw new Error(err.error ?? "オプション取得に失敗しました"); + throw new Error("HTTP " + optRes.status + ": " + rawText.slice(0, 200)); } - const optJSON = await optRes.json(); - setStep("1c. JSON パース OK"); await tick(); + let optJSON: Record; + try { + optJSON = JSON.parse(rawText); + } catch (e) { + throw new Error("JSON.parse 失敗: " + String(e) + " | body: " + rawText.slice(0, 100)); + } + setStep("1d. JSON パース OK"); await tick(); const userId = b64urlToBuffer(optJSON.user.id); const challenge = b64urlToBuffer(optJSON.challenge); -- cgit v1.2.3