🐛 fix(auth): skip body parser for Stripe webhooks

The JSON body parser was consuming the request body before NestJS
could access the rawBody needed for Stripe webhook signature
verification. Now webhooks to /api/v1/webhooks/stripe skip the
body parser middleware.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2026-02-16 12:01:24 +01:00
parent bfc2737ce5
commit d86e9031bb
15 changed files with 238 additions and 191 deletions

View file

@ -77,7 +77,14 @@ async function bootstrap() {
app.use(cookieParser());
// Explicit body parsers for form-urlencoded (needed for OAuth2 token endpoint)
app.use(bodyParser.json());
// IMPORTANT: Skip JSON body parsing for Stripe webhooks to preserve rawBody for signature verification
app.use((req: Request, res: Response, next: NextFunction) => {
if (req.path === '/api/v1/webhooks/stripe') {
// Skip body parsing for Stripe webhooks - NestJS rawBody will be used instead
return next();
}
bodyParser.json()(req, res, next);
});
app.use(bodyParser.urlencoded({ extended: true }));
// CORS configuration