Overcome axios 413 file is too large error while upload files

I have a react app with this site id: c1c40b52-6ac2-425c-ad35-b8e61d32d4dc
and this is serverless function endpoint with this site id: 925f9b60-a694-47a1-b41a-d34bb0c156f7

I have an image upload api which uploads images to aws s3 endpoint.
When i upload an image from the react endpoint on the netlify deployment backend - i get an exios error of 413 for certain large files. There is no certainty in the size. For some 4 mb files it fails, for some 6mb files it passes. This does not fail on my local deployment.

I tried adding these limits to the middleware but with no luck:
const jsonParser = bodyParser.json({
limit: ‘10mb’
const urlEncoded = bodyParser.urlencoded({limit: ‘10mb’, extended: true});

The api is not called when the image is big - so tis not a failure from aws. Theres a step before that where this request is rejected.

Is there a netlify config that i need to update for this? I dont mind it failing with this error - but i want it to fail for an expected size. Where is this limit configured? Any pointers will help


Hiya :wave:t6: , thanks for reaching out! In the case of Netlify, the limit for file uploads is set to 50MB by default. Although I see the file size is 10mb it’s possible that the request is being rejected by another layer before it reaches Netlify?

To troubleshoot this issue, here are a few suggestions:

  1. Check if the error occurs consistently: You can test different file sizes and monitor the requests and responses using browser developer tools or server logs.
  2. Verify the serverless function code: Double-check the code and any configurations related to file size limits. You mentioned using bodyParser middleware, but make sure it is correctly configured for your specific function.

Finally, it would help if you had a link to the function log + repo.