Reputation: 195
I am trying to POST call using Router through express but I am getting request entity too large error, can anyone please help to solve the issue?
I want to set mb limit to my POST call payload. I have tried app.use() limit setting through body-parser but seems to get the same issue.
Thanks
Upvotes: 7
Views: 13037
Reputation: 105
For total noobs like me be sure to either just use bodyParser.json or express.json I had both of these in my code and so no amount of changing body parser helped because it was using express.json to handle requests.
app.use(express.json());
const bodyParser = require('body-parser');
app.use(bodyParser.json());
there is a larger thread for this over on the other link.
Error: request entity too large
Upvotes: 3
Reputation: 1521
The default request size is 100kb in body-parser. try this
app.use(bodyParser.json({limit: '5mb'}));
app.use(bodyParser.urlencoded({limit: '5mb', extended: true}));
make sure to add this before defining the routes
Upvotes: 9