fix: skip express.json for stripe webhook to preserve raw body

This commit is contained in:
posimai 2026-04-05 14:54:39 +09:00
parent 955da8899b
commit 8fdcb65f4b
1 changed files with 7 additions and 1 deletions

View File

@ -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 環境変数(カンマ区切り)+ 開発用ローカル