Nest: express 4.16 bodyparser options not applied

Created on 1 Dec 2017  路  5Comments  路  Source: nestjs/nest

Hi,

Since the update to 4.3.x I receive 413 errors when posting large form datasets, regardless of which body-parser library i use.

Original

app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({ extended: true }));

New

app.use(express.json({limit: '50mb'}));
app.use(express.urlencoded({ extended: true }));

Is anyone else encountering issues with body-parser? it seems like whatever options I set are ignored.

Further Testing, no issues using Nest 4.2, maybe related to:

core: json and urlencoded (body-parser) middlewares are applied by default now, bugfix #252
https://github.com/nestjs/nest/issues/252

I see that bodyparser gets set in nest-application.ts

public setupParserMiddlewares() {
    this.express.use(bodyParser.json());
    this.express.use(bodyParser.urlencoded({ extended: true }));
}

But shouldn't I be able to override these with the above statements when starting server.js?

type todo 馃挌

Most helpful comment

Hi @Yang010 @danapier,
Will be fixed in the nearest update.

All 5 comments

We need to set bodyParser.json({strict: false}) in our app.

Hi @Yang010 @danapier,
Will be fixed in the nearest update.

Please update your package into 4.5.0 and let me know whether it helps you 馃檪

fixed in 4.5.x, thanks!

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FranciZ picture FranciZ  路  3Comments

menme95 picture menme95  路  3Comments

artaommahe picture artaommahe  路  3Comments

yanshuf0 picture yanshuf0  路  3Comments

rlesniak picture rlesniak  路  3Comments