iron-meteor/iron-router

Request entity too large error

KillianRousseau opened this issue · 0 comments

Hi,

I'm trying to send data from a node js server to a meteor app. In the node js I'm doing this :
axios.put('http://localhost:3000/api/project/'+id,{"data" :data, "idExtractor":idExtractor, "version":getVersion()})
where data is a string of the XML given by our server

And in my meteor app I'm receiving this in a server route, but when the data is too large, the meteor server give me the errors "socket hang up" and "request entity too large".

I tried solutions from 710 and other issues, doing the following code in the lib/Router.js file. I tried to put it before all routes definitions, before REST routes, after all routes, I also tried to put it in server/main.js in the startup block

if (Meteor.isServer) {
Router.onBeforeAction( Iron.Router.bodyParser.raw({type: '/', only: ['creditReferral'], verify: function(req, res, body){ req.rawBody = body.toString(); }, where: 'server'}));
Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
extended: true,
limit : '10mb'
}));
Router.onBeforeAction( Iron.Router.bodyParser.urlencoded({ extended: true, limit : '10mb' }), {where: 'server'});
}

I also tried to change these limits in the node server with this

express.urlencoded({limit: '10mb', extended: true, type: "application/x-www-form-urlencoded"})
express.json({limit: '10mb', strict: false, type: "application/json"})
app.use(bodyParser.json({limit: '10mb'}));
app.use(bodyParser.urlencoded({ extended: true, limit :'10mb' }));

But I always have the same problem, all help would be greatly appreciated.

Edit :

Solved this problem, here is how I fixed it https://stackoverflow.com/questions/51193351/meteor-iron-router-error-request-entity-too-large/51381478#51381478