Search code examples
node.jsfile-uploaduploadbody-parsernodebb

NodeBB error when upload file - Request Entity Too Large


I'm getting a visual error when trying to upload a file with 2.6MB. This says:

Request Entity Too Large.

enter image description here

Even with upload configurations enabled to 20MB.

enter image description here

I've read that this error is related to bodyParser limit, so i tried to solve this changing lines on nodebb/src/webserver.js lines 157 and 158

From this

app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());

to this (with no success)

app.use(bodyParser.urlencoded({ extended: true, limit: '20mb'}));
app.use(bodyParser.json({limit: '20mb', type: 'application/json'}));

I've also searched in Nodebb repository, but there's no problem like that. If someone could help me on that, i will be greatful.


Solution

  • If your app is behind nginx you need to set the limit in nginx as well. Add client_max_body_size 5M; into your nginx config.