Mingyang Yuan
Mingyang Yuan

Reputation: 51

NextJS got 413 "Entity too large" response

I'm using formidable to deal with file upload stuff in my NextJS project. To use formidable inside NextJS I have to set bodyParser to false for the upload API cos formidable need to get the file from Stream. Everything went well in the development environment(No matter how big the file is). But I'll get a 413 response from the production when I try to upload a larger file(about 10mb, actually not big at all).

In my opinion, the bodyParser shouldn't block the bigger file even if I didn't set a sizeLimit property cos the bodyParser itself was set to false.

Does anyone get some ideas on how to solve this?

Upvotes: 1

Views: 5831

Answers (1)

Mingyang Yuan
Mingyang Yuan

Reputation: 51

Finally figured out that it's Vercel limits the payload size for the request body.

Serverless Function Payload Size Limit

The maximum payload size for the request body or the response body of a Serverless Function is 4.5 MB.

If a Serverless Function receives a payload in excess of the limit it will return an error → 413: FUNCTION_PAYLOAD_TOO_LARGE.

Reference doc: https://vercel.com/docs/concepts/limits/overview#serverless-function-size

Upvotes: 3

Related Questions