I'm trying to send data from a node js server to a meteor app. In the node js app 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 on a server route in lib/Router.js file, but when the data is too large, the meteor server gives me the errors "socket hang up" and "request entity too large".
I tried solutions from the issues of Iron Router on github, doing the following code in the Router.js file.
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 tried to put it before all routes definitions, before server routes, after all routes, I also tried to put it in server/main.js in the startup block.
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"
})
and this
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.
After trying many solutions, I fixed this problem with this in my Router.js :
This fixed the entity too large error, but because the data is xml in this request, I couldn't directly parse it to json, so I needed to change my
to the following :
and it worked. Hope this could help someone having the same issue.