NodeJS Router payload too large

You can use this straightaway in express if you are using the latest version of express.

    let express = require('express');

    let app = express();

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

Please note that this will only work with express versions bundled with bodyParser (bodyParser was added back to express in release 4.16.0)


I found the solution for my problem in one of the unaccepted answers of the suggested duplicate of TKJohn. I had to add the parameter limit so that my code became:

var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true, parameterLimit: 50000 }));

After the addition it worked!

I was also ablo to remove the code from APIRoutes.js

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