mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:41:09 +02:00
fix(auth): remove conflicting JSON body parser middleware
The manual bodyParser.json() middleware conflicts with NestJS rawBody mode. When rawBody: true is enabled, NestJS consumes the body stream first, then the manual parser tries to read it again causing "stream is not readable". NestJS handles JSON parsing internally, so the manual middleware was redundant and causing 500 errors on login requests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f5a6fda0fa
commit
20db01628a
1 changed files with 4 additions and 9 deletions
|
|
@ -76,15 +76,10 @@ async function bootstrap() {
|
|||
);
|
||||
app.use(cookieParser());
|
||||
|
||||
// Explicit body parsers for form-urlencoded (needed for OAuth2 token endpoint)
|
||||
// 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);
|
||||
});
|
||||
// Body parser for form-urlencoded (needed for OAuth2 token endpoint)
|
||||
// Note: JSON body parsing is handled by NestJS internally (rawBody: true mode)
|
||||
// DO NOT add bodyParser.json() here - it conflicts with NestJS rawBody mode
|
||||
// and causes "stream is not readable" errors
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
|
||||
// CORS configuration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue