File upload with blob returning 413

I’m trying to upload a file using Vercel blob. It works just fine on localhost and the files goes to the blob server of Vercel. But when I try to do the same thing online, on my domain .vercel.app, I get the following error:

Application error: a client-side exception has occurred (see the browser console for more information).

The console says:

3:1       
        
Failed to load resource: the server responded with a status of 413 ()
7023-82de977989e9105f.js:1 TypeError: Cannot read properties of undefined (reading 'error')
    at u (page-2db8d2d13e6cb5be.js:1:6431)
    at rE (fd9d1056-552ebe227f6ea7cd.js:1:40342)
    at l$ (fd9d1056-552ebe227f6ea7cd.js:1:59317)
    at iZ (fd9d1056-552ebe227f6ea7cd.js:1:117924)
    at ia (fd9d1056-552ebe227f6ea7cd.js:1:95163)
    at fd9d1056-552ebe227f6ea7cd.js:1:94985
    at il (fd9d1056-552ebe227f6ea7cd.js:1:94992)
    at oJ (fd9d1056-552ebe227f6ea7cd.js:1:92348)
    at oZ (fd9d1056-552ebe227f6ea7cd.js:1:91767)
    at MessagePort.T (7023-82de977989e9105f.js:1:83896)
  1. Ok, the file is too large, but when I try to upload through localhost, directly to the blob server, it works. Why’s that?
  2. Is it possible to bypass this limitation of size? What if I become pro on Vercel?

Hi, @treinomix!

Thank you for all the details! :pray:

When you’re uploading directly from localhost to the Vercel Blob server, you’re likely using a client-side upload method that sends the file directly to Vercel’s Blob storage. This method bypasses your server entirely, allowing for larger file uploads.

However, when you’re uploading through your .vercel.app domain, the request is going through your serverless function first. Vercel has a limit on the request body size for serverless functions, which is 4.5 MB. This explains why you’re getting a 413 error (Request Entity Too Large) when trying to upload larger files through your deployed application.

Unfortunately, the 4.5 MB limit for serverless functions is a hard limit that applies to all Vercel plans, including Pro and Enterprise . Upgrading your plan won’t increase this limit.

However, you can bypass this limitation by using client-side uploads. Here’s how you can do it:

  1. Use the client-side upload method provided by Vercel Blob SDK.
  2. Generate a presigned URL on your server for the client to upload directly to Blob storage.

See also: How do I bypass the 4.5MB body size limit of Vercel Serverless Functions?

Let us know how you get on!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.