8

I am receiving following error with mean.io application.

Error: request entity too large

To overcome this issue, I have increased the bodyParser limit with in meanio module at following location.

node_modules/meanio/lib/core_modules/server/ExpressEngine.js

// Request body parsing middleware should be above methodOverride
  this.app.use(expressValidator());
  this.app.use(bodyParser.json({limit: '50mb'}));
  
  this.app.use(bodyParser.urlencoded({
    limit: '50mb',
    extended: true
  }));
  this.app.use(methodOverride());

However this is a bad practice and the changes will be lost if we upgrade the module. Can anyone suggest any alternative way to increase request limit at meanio app?

4 Answers4

11

Try to apply this in your app.js instead.

app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb'}));

Hope this help!

Zachary Dahan
  • 1,279
  • 15
  • 26
8

2016, none of the above worked for me until i explicity set the 'type' in addition to the 'limit' for bodyparser, example: var bodyParser = require('body-parser');

  var app = express();
  var jsonParser       = bodyParser.json({limit:1024*1024*20, type:'application/json'});
  var urlencodedParser = bodyParser.urlencoded({ extended:true,limit:1024*1024*20,type:'application/x-www-form-urlencoding' })

  app.use(jsonParser);
  app.use(urlencodedParser);
user1709076
  • 2,066
  • 7
  • 31
  • 50
  • HI I am also facing the same problem... I didnot get a solution http://stackoverflow.com/questions/40508748/custom-code-parsing-issue-request-entity-too-large-oracle-mcs – Arj 1411 Nov 10 '16 at 13:16
2

What I got to work was putting those two lines directly var app = express(); like so:

```

var app = express();
app.use(morgan('dev'));
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));

```

Andy Brown
  • 21
  • 2
1

I got this working actually it is the issue with npm meanio module in the latest version they have updated the code. You need to update the npm meanio package.After that you can able to overide the methods that are present in ExpressEngine.js file.

There is a issue opened for this on github https://github.com/linnovate/mean/issues/1169

After this they have fixed this issue and merged the code

Sunil Hirole
  • 239
  • 3
  • 10