Express JavaScript Answers

How to Fix the ‘Error: request entity too large’ in Express and JavaScript?

Spread the love

To fix the ‘Error: request entity too large’ in Express, we can set the limit option when we add body-parser into our Express app.

For instance, we can write:

const express = require('express')
const app = express()
const port = 3000
const bodyParser = require('body-parser')
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));'/', (req, res) => {

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)

to set the max size of JSON and URL encoded request data to 50MB by setting limit to '50mb' .

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.