Skip to content

Improve admin upload error for Vercel 4.5 MB function body limit #16484

@Nico924

Description

@Nico924

Describe the Feature

When a Payload app is deployed on Vercel and media uploads are sent through the server upload path, files larger than Vercel Functions' request body limit fail with a raw 413 Content Too Large / FUNCTION_PAYLOAD_TOO_LARGE network error.

It would be helpful if the Payload admin upload UI could detect this failure and show a clearer message with file-size context, for example:

Upload failed: this file is 5.1 MB, but this deployment can only accept about 4.5 MB through the server upload route. Enable client uploads for your storage adapter, or upload a smaller file.

Use Case

In a Payload 3 + Next.js + Vercel deployment using @payloadcms/storage-vercel-blob, uploading a 5.1 MB PDF to /api/media?depth=0&fallback-locale=null failed online with:

POST https://example.vercel.app/api/media?depth=0&fallback-locale=null 413 (Content Too Large)

The same file worked locally, and the Payload config had a larger upload limit, so the root cause was not obvious from the admin UI.

The fix was to enable direct client uploads:

vercelBlobStorage({
  collections: { media: { disablePayloadAccessControl: true } },
  clientUploads: true,
  token: process.env.BLOB_READ_WRITE_TOKEN,
})

Proposed Improvement

When an admin upload request receives HTTP 413, display a specialized upload error that includes:

  • the selected file size in MB
  • the server/provider response status, e.g. 413 Content Too Large
  • guidance that hosted/serverless providers may have lower request body limits than Payload's configured upload.limits.fileSize
  • for Vercel Blob / cloud storage adapters, a hint to enable clientUploads

This would make the problem understandable without needing to inspect the browser console/network tab.

Related Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions