nextjs - 💡(How to fix) Fix Next.js 16: file uploads via Server Actions lose file on first call when using proxy.ts (dev only; mp3/mp4) [7 comments, 6 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#85348Fetched 2026-04-08 02:16:17
View on GitHub
Comments
7
Participants
6
Timeline
12
Reactions
7
Author
Timeline (top)
commented ×7labeled ×2subscribed ×2issue_type_added ×1

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 24.10.0
  npm: 11.6.1
  Yarn: N/A
  pnpm: 10.18.0
Relevant Packages:
  next: 16.0.0 // Latest available version is detected (16.0.0).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/nghiepdev/next16-server-action-proxy-uploadfile-mp34-bug

To Reproduce

  1. Run next dev.
  2. Select a file.
  3. Click Upload.
  4. Check the terminal — the file is missing on the first attempt.
  5. Click Upload again.
  6. The terminal now logs the file.

Current vs. Expected behavior

In development mode, when ‎proxy.ts is configured, the first call to a server action that uploads an mp3/mp4 results in the uploaded file being missing or empty. Subsequent calls work. Image uploads do not exhibit this problem.

Expected: All file types (including mp3/mp4) should be consistently available to server actions on the first call in development, regardless of proxy configuration.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:50 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12
Binaries:
  Node: 24.10.0
  npm: 11.6.1
  Yarn: N/A
  pnpm: 10.18.0
Relevant Packages:
  next: 16.0.0 // Latest available version is detected (16.0.0).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Server Actions, Middleware

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

Problem occurs only in development. If I remove proxy.ts, the bug no longer appears. Also, the issue does not occur with JPEG files.

extent analysis

TL;DR

The issue can likely be resolved by adjusting the proxy.ts configuration to properly handle mp3/mp4 file uploads in development mode.

Guidance

  • Review the proxy.ts file to ensure it is correctly configured for handling multipart/form-data requests, which are typically used for file uploads.
  • Verify that the proxy.ts configuration is not interfering with the upload process by checking for any logging or debugging statements that may indicate where the issue lies.
  • Test the upload process with different file types to confirm that the issue is specific to mp3/mp4 files and not a general problem with file uploads.
  • Consider adding logging statements to the server action code to track the file upload process and identify where the file is being lost.

Example

No specific code example can be provided without more information about the proxy.ts configuration and server action code. However, ensuring that the proxy.ts file is set up to handle multipart/form-data requests correctly is crucial. For example, using a library like http-proxy-middleware might require specific configuration for handling such requests.

Notes

The issue seems to be related to the interaction between the proxy.ts configuration and the server action code in development mode. The fact that removing proxy.ts resolves the issue suggests that the problem lies in how the proxy is handling file uploads.

Recommendation

Apply a workaround by adjusting the proxy.ts configuration to correctly handle mp3/mp4 file uploads, as the root cause appears to be related to this configuration.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING