1

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.

Marcos Mendes
  • 1,091
  • 1
  • 8
  • 15
  • Seems to be an Express related error and googling "nodejs Request Entity Too Large" brings ~50k results... – marekful Jan 29 '18 at 05:12
  • Possible duplicate of [Error: request entity too large](https://stackoverflow.com/questions/19917401/error-request-entity-too-large) – marekful Jan 29 '18 at 05:12

1 Answers1

3

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.

Barış Uşaklı
  • 13,440
  • 7
  • 40
  • 66
  • Thanks for taking time to help, i'll check if NodeBB is behind nginx, i give you some feedback when i test. – Marcos Mendes Feb 01 '18 at 13:47
  • 1
    Several years later i'm back to thank you, this is the right solution. For more details, you need to put this property inside location / {} at nginx/sites-available/mysiteconf – Marcos Mendes Jan 05 '23 at 00:46