Vercel Functions can now accept request bodies up to 20MiB, up from 4.5MB, Vercel’s changelog says. The feature is in Public Beta. A request body is the data a browser sends to your backend, such as a photo, a PDF, or a large form submission. A function is the small piece of backend code Vercel runs for each request.

If your app rejects uploads just over 4.5MB, this is the limit you are hitting. Oversize requests to Edge runtime functions, which keep the old cap, still fail with a 413 error, which means “payload too large.”

How to turn it on

Set the environment variable VERCEL_SUPPORT_LARGE_REQUEST_BODY=1. It applies to the whole project in the environment where you set it, so you can try it on a preview deployment before enabling it in production.

Three conditions apply:

  • The project’s functions must use the 4GB performance memory setting.
  • It works on the Node.js, Python, and Bun runtimes, and in Routing Middleware.
  • Functions and Routing Middleware on the Edge runtime keep the 4.5MB cap. To move them to the larger limit, switch the function to the Node.js runtime with runtime: 'nodejs', or use proxy.ts in Next.js.

Middleware no longer sees the body

Routing Middleware is code that runs before a request reaches your function, often to check or redirect it. Once a project opts in, it receives request headers and metadata but not the request body. It still runs and still sees every other header. Vercel says this avoids sending the body twice, to middleware and to the target function, which would raise cost and time to first byte.

Any middleware that checks the body of a request, for example to validate a form field before it reaches your function, will stop working for that project. Move that check into the function itself before you enable the variable in production.

Read large bodies promptly

Vercel advises reading the body as soon as it arrives rather than holding it in memory, to avoid backpressure and memory problems. Backpressure is what happens when data arrives faster than your code processes it. If you ask a coding agent to build the upload handler, tell it to process the file as it arrives and not to load the whole 20MiB into memory first.


End of article