PARAS MADAN
All writing

Latest in AI

Vercel Functions' 20 MiB Request Beta: Fix the 413 Without Breaking Middleware

Check runtime and memory requirements, test larger requests in Preview, and decide when direct uploads are still a better fit.

If your AI app accepts PDFs through a Vercel Function, a document can fail before your parser or model sees it. Vercel's November 20 beta raises the inbound request ceiling for eligible Functions. The change is useful, but I would check the whole request path before turning it on. An upload route can start working while a different route loses a middleware check it relied on.

Find where the 413 comes from

Start with the failing response. Vercel's payload error guide identifies FUNCTION_PAYLOAD_TOO_LARGE as its 413 error. If your application, framework or an upstream service enforces a smaller limit, raising Vercel's limit will not remove that restriction.

Measure the request you actually send, not the file in the picker. A multipart upload includes its form fields and boundaries, and a base64 file inside JSON takes more space than the original binary. Also check whether your problem is sending a large request or returning a large response. This beta announcement is about inbound bodies.

Enable it in Preview first

Vercel's release announcement says to set VERCEL_SUPPORT_LARGE_REQUEST_BODY=1 in the project environment. Set it for Preview and redeploy there first. The switch applies to the project in that environment, not just to your upload endpoint.

The beta supports Node.js, Python and Bun Functions with Performance memory at 4 GB; the error guide also specifies Fluid compute. The Edge runtime keeps its 4.5 MB cap. If the route uses Edge, plan and test a runtime change separately rather than treating the environment variable as a fix.

Check middleware even on smaller requests

The release notes say Routing Middleware still receives headers and metadata after opt-in, but it no longer receives the body. This is a project-level change, so a small webhook can be affected even if the original problem was a large document upload.

Look for middleware that parses JSON, reads a form field or checks a signature over raw request bytes. If validation needs the body, keep it in the destination handler before parsing or acting on the payload, or leave the beta off until you have a safe design. Do not compensate for the missing body by accepting an unsigned request.

Test with files you can throw away

Use a Preview deployment and synthetic files. Compare a small request that passed before, a representative request above the old cap and within the new one, and a request above the new cap. Use the same encoding as production. For the middle case, confirm your handler receives the whole body and returns the expected output. For the last case, check that your client reports the size error clearly.

Then run a normal signed webhook and an invalid one. The valid request should still arrive and the invalid one should still be rejected. If a parsing library buffers the whole file, watch memory and latency with more than one simultaneous upload before expanding the rollout.

Use direct upload when the file is the workload

For a moderately larger inbound webhook or JSON request, the beta may be the simplest fit. For file intake with unpredictable sizes, I would usually send the file straight to storage and pass a reference to the processing step. Vercel Blob's client upload guide shows that pattern and calls out authenticating and authorizing the user before granting an upload token.

The better test is not whether one big file passes. It is whether the new path handles your real request sizes and preserves the checks the old one enforced.

I'm Paras. I help technical teams explain product changes, write practical setup guides, and show readers what to check before they depend on a new feature. Book a 30-minute call.