Big uploads fail live? Check size limits
You tested the upload form with a small screenshot and it worked. Then real people started using it. A customer tries to attach a photo from their phone, or a ten-page PDF, and nothing happens. Maybe a spinner never ends, or there is no message at all, and the file never arrives. The file just hit a limit you did not know existed.
The symptom
- Small files upload fine; larger ones fail every time.
- It worked in preview with your test files, but fails for real visitors.
- The browser network tab shows a
413status (Payload Too Large), or a request that is cut off or times out.
The cause
Every layer between the browser and your storage can cap how big a request may be, and each has its own default. The smallest one wins. Common ones:
- Serverless functions. If the file passes through a function before reaching storage, the host's request size limit applies. Vercel Functions cap the request body at 4.5 MB. Netlify's standard functions have a payload limit of about 6 MB.
- Framework defaults. Next.js Server Actions accept 1 MB by default unless you raise
serverActions.bodySizeLimitin the config. Express'sexpress.json()parser defaults to 100 KB, which a base64-encoded image passes easily. - Storage settings. Supabase Storage has a project-wide file size limit, and each bucket can set its own
file_size_limitand allowed file types. A bucket limited to images will reject a PDF. - Base64 bloat. AI-generated code often converts a file to a base64 string and sends it inside JSON. That makes it about a third larger, so a 4 MB photo becomes more than 5 MB on the wire.
Phone photos are often several megabytes, far bigger than a test screenshot.
Step-by-step diagnosis
- Reproduce with a big file. Pick a file of 8 to 10 MB and try it on the live site, not the preview.
- Open the browser's developer tools, Network tab. Find the upload request. Note the status code, the URL it went to, and the response body. A
413or a host error code such asFUNCTION_PAYLOAD_TOO_LARGEnames the culprit directly. - Check where the request went. If the URL is your own
/api/...route or a server action, the file passes through a function, and the function limit applies. If it goes straight to your storage provider, look at the storage settings instead. - Check the request body. If the payload is a long string of letters inside JSON, the code is sending base64, and the real size is larger than the file on disk.
- Read the server or function logs for the same minute; errors like "request entity too large" appear there.
- Check storage limits. In Supabase, look at the Storage settings for the global file size limit, then at the bucket's own size and file type settings.
Fixes per builder or host
Lovable and other Supabase-backed builds
Upload from the browser straight to Supabase Storage with the client library, rather than through an Edge Function. For private files, have the server create a signed upload URL and let the browser upload to it. Set the bucket's size limit and allowed types deliberately. Supabase recommends its resumable upload method for files larger than about 6 MB.
v0 and Next.js on Vercel
Do not push files through a route handler or server action if they can exceed 4.5 MB. Use client uploads to Vercel Blob, or a presigned URL to S3 or a similar store, so the file goes straight from the browser to storage and only the resulting URL reaches your function. If you must use a server action for small files, raise bodySizeLimit to a sensible value.
Bolt and Netlify
Keep large files out of function payloads: upload directly to storage with a signed URL and pass only the file's address to the function.
Replit and Cursor projects on your own server
Check the body parser limits in your server code, for example express.json({ limit: '10mb' }), or better, use a multipart upload handler that streams to storage. If you run behind Nginx, its client_max_body_size defaults to 1 MB.
Everywhere
- Resize or compress images in the browser before uploading.
- Check the file size before sending and show a clear message, such as "Files must be under 10 MB".
- Show the real error when an upload fails, instead of a silent spinner.
How to verify
- Upload a small file, a file just under your limit, and one just over it, on the live domain.
- Confirm the first two land in storage and are linked to the right record.
- Confirm the third shows your clear size message instead of hanging.
Prevention
- Write your upload limit down and make the form, the storage bucket and any function agree on it.
- Keep a large test file and include it in your checks before each release.
- Watch the live site from outside, so a broken form or failing page gets noticed before a customer emails you about it.
Size limits stay invisible until a real visitor hits one, so test with a big file before they do.
