From 8fdcb65f4bffa09606e565fddaef3caf8fd66e23 Mon Sep 17 00:00:00 2001 From: posimai Date: Sun, 5 Apr 2026 14:54:39 +0900 Subject: [PATCH] fix: skip express.json for stripe webhook to preserve raw body --- server.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index fbd74b5b..03e504c9 100644 --- a/server.js +++ b/server.js @@ -109,7 +109,13 @@ async function createSessionJWT(userId) { } const app = express(); -app.use(express.json({ limit: '10mb' })); +// Stripe Webhook は raw body が必要なため、webhook パスのみ json パースをスキップ +app.use((req, res, next) => { + if (req.path === '/brain/api/stripe/webhook' || req.path === '/api/stripe/webhook') { + return next(); + } + express.json({ limit: '10mb' })(req, res, next); +}); // ── CORS ────────────────────────────────── // ALLOWED_ORIGINS 環境変数(カンマ区切り)+ 開発用ローカル