Error: request entity too large (I am not using body parser)
I am receiving the error "Error: request entity too large" when I am trying to send large JSON data in my body. But I am not using a body parser. I have written my own middleware for collecting the chunk of data. Is there a way to increase to limit of the body ?
function bodyBufferParser(req, res, next) {
var data = "";
req.on("data", function(chunk) {
data += chunk;
});
req.on("end", function() {
try {
if(data){
req.rawBody = data;
req.jsonBody = JSON.parse(data);
}
}
catch(ex) {
logger.error("Exception caught", ex);
ResponseHandler(res, kResponseCode.badRequest, "Invalid JSON format.");
return;
}
next();
return;
});
}
By default there is no size limit nor anything in Express.js that would send back that response (only in body-parser whixh you noted you are not using).
Can you provide all the following?
- Version of Node.js
- Version of Express.js
- Complete server code we can run to reproduce the issue.
- Complete instructions on how to make the request to get that response back from the server code you provided.
Thanks!
Thanks for the reply Doug. Here is what you have asked for.
- Node version : v6.10.0
- Express version : ^4.14.0
3 & 4. I cannot actually give you that because of all the things involved in it. What we are doing is that sending a more than 5MB of JSON data to the server from react client so that we can go some sort of processing on it and then generate an excel file and save it on server itself. We have successfully generated excel files up to 2MB which may have around I guess 1.5 - 1.7 MB of data.
Hi @kirtanshetty without number3 & 4 I'm not sure how I can help. As I said, there is no size limit nor anything in Express.js that would send back that response (only in body-parser whixh you noted you are not using). Not sure why you are getting that without being able to see anything. If you have any thoughts on how I can help, please let me know and I can re-open.