I\'m using Node.js and express.
I would like to limit the HTTP request size. Let\'s say, if someone sends me a HTTP request more than 2 MB then I stop the request r
For an updated solution that isn't deprecated, you can add the limit like so, in your app.js file:
app.use(express.json({limit: '2mb'}));
app.use(express.urlencoded({limit: '2mb', extended: false}));
You can also do it like this:
app.use(express.json({limit: 2000000}));
app.use(express.urlencoded({limit: 2000000, extended: false}));