Skip to content

s3Storage clientUploads still sends file binary to Server Action, causing 413 error #15073

Closed

Description

@du2333

Describe the Bug

Description

When clientUploads: true is enabled in s3Storage plugin, the initial create request (Next.js Server Action) still includes the full file binary in the multipart form data. This causes a 413 Payload Too Large error due to Next.js's default 1MB limit for Server Actions, defeating the purpose of client-side uploads.

Reproducible Code

// payload.config.ts
plugins: [
    s3Storage({
      collections: {
        media: {
          generateFileURL: ({ filename }) => `${process.env.FRONTEND_URL}/images/${filename}`,
        },
      },
      clientUploads: true,
      bucket: process.env.R2_BUCKET_NAME || '',
      config: {
        credentials: {
          accessKeyId: process.env.R2_ACCESS_KEY_ID || '',
          secretAccessKey: process.env.R2_SECRET_ACCESS_KEY || '',
        },
        region: 'auto',
        endpoint: process.env.R2_ENDPOINT || '',
      },
    }),
  ],
Image

Link to the code that reproduces this issue

https://github.com/du2333/payloadcms-reproduction-repo

Reproduction Steps

  1. Enable s3Storage with clientUploads: true.
  2. Upload a file larger than 1MB (e.g., 5MB) via the Admin UI.
  3. Observe the 413 error in the console.
  4. Check the Network tab: the /admin/collections/media/create POST request contains the file binary.

Which area(s) are affected?

plugin: storage-*

Environment Info

Binaries:
  Node: 22.15.0
  npm: 10.9.2
  Yarn: N/A
  pnpm: 10.25.0
Relevant Packages:
  payload: 3.69.0
  next: 15.4.10
  @payloadcms/db-postgres: 3.69.0
  @payloadcms/drizzle: 3.69.0
  @payloadcms/graphql: 3.69.0
  @payloadcms/next/utilities: 3.69.0
  @payloadcms/plugin-cloud-storage: 3.69.0
  @payloadcms/plugin-seo: 3.69.0
  @payloadcms/richtext-lexical: 3.69.0
  @payloadcms/storage-s3: 3.69.0
  @payloadcms/translations: 3.69.0
  @payloadcms/ui/shared: 3.69.0
  react: 19.2.1
  react-dom: 19.2.1
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Tue Nov 5 00:21:55 UTC 2024
  Available memory (MB): 15951
  Available CPU cores: 16

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Jan 1, 2026
  2. added and removed
    validate-reproduction
    on Jan 1, 2026
  3. timothylp commented on Jan 2, 2026

    @timothylp

    Apologies for linking a separate issue here, but they seem to share the same scope. I'm bringing this up again because it's a major blocker that makes clientUploads unusable for my use case.

    It's very likely these two issues are interconnected or share a common root cause. I’d really appreciate it if someone could take a look, as my initial report has been stalled for a while now.

    Related issue: #12671

  4. sohamingle commented on Jan 3, 2026

    @sohamingle

    I traced this back to how the form is wired up with getFormState and its associated Server Action which is used for validation, rendering and permissions.

    Because Server Actions are subject to Next.js’ request body size limits (~1 MB by default), this results in a 413 Payload Too Large error for larger files, despite client uploads being enabled.

    I’ve prepared a fix that adjusts this flow so the file binary is not passed through the getFormState Server Action.

  5. removed
    status: needs-triage
    on Jan 5, 2026
  6. rilrom commented on Jan 12, 2026

    @rilrom
    Contributor

    I'm able to reproduce this in my image search plugin, which doesn't use any adapter.

    Looks like the PR to resolve this is already aware of this, but flagging it here nonetheless.

  7. github-actions commented on Jan 13, 2026

    @github-actions
    Contributor

    🚀 This is included in version v3.71.0

  8. github-actions commented on Jan 21, 2026

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  9. locked as resolved and limited conversation to collaborators on Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions