Don’t use bodyParser middleware anymore with ExpressJS…

AntoineGGG
2 min readAug 2, 2022
Photo by Denys Nevozhai on Unsplash

When you work with an express server, you can use the bodyParser middleware to your app with the app.use() function to extract the body of request stream to attach it to the req.body object.

You can then process the req.body object to manipulate data for your business logic.

Sometimes, when you work with a lots of data, you could see an error from your express server: “Request entity too large”, which means that you reach the default limit (100kb) managed by the body parser middleware.

In my case it was a page builder that sent html, css, and components of a library to my Express server, making the weight of the body request too heavy and this error appears, preventing our client to create more content.

With the bodyParser middleware, you can pass it some options to increase the size of your body request and let all your data pass to your back-end like this:

After some research in stack overflow and more, I saw a lot of people get confused about the way to manage this limit, the main recurrent question is: Should I use body parser or express built-in middleware, or maybe both…?

--

--