iron-meteor / iron-router

A client and server side router designed specifically for Meteor.
MIT License
1.98k stars 413 forks source link

request too large || body empty when increasing limit #1500

Open quape opened 8 years ago

quape commented 8 years ago

I'm sending a json-ecoded POST request from outside to meteor which shall be captured by iron router like this:

Router.map(function () {
this.route('api', {
    path: '/api',
    where: 'server',

    action: function() {
        var o = this.request.body
        ...

This works when the request is small. When it is about 1 MB, I get a Error: Request Entity Too Large. So I used:

Router.configureBodyParsers = function() {
    Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
        limit: '500mb'
    }))
};

to increase the request size limit. But then, this.request.body is empty. What to do?

ThomsCass commented 8 years ago

+1

micahalcorn commented 7 years ago

In my case, I had followed issue #710 and increased the limit on the urlencoded parser. This solution appears to overwrite the default configuration (which includes the json parser), so I had to add it to the solution in order for both the large requests to be accepted and also get request.body to be populated.

Router.configureBodyParsers = function () {
  Router.onBeforeAction(Iron.Router.bodyParser.json());
  Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
    extended: true,
    limit : '500mb'
  }));
};
kkm commented 7 years ago

@micahalcorn can you explain me? it doesnt work with me.