Environment
Next.js 13 app deployed to Vercel using serverless Node.js functions (not Edge runtime). API route /api/ingest accepts JSON up to 25MB and sets export const config = { api: { bodyParser: { sizeLimit: '25mb' } } }. Clients report intermittent HTTP 413 when function cold-starts; retries usually succeed.
Symptoms
Client uploads of 12–20MB JSON intermittently receive 413 Payload Too Large immediately, predominantly during periods with increased cold-starts (deploys or traffic spikes). The 413 is returned before application middleware logs the request. Local Vercel CLI doesn't reproduce 413s.
Observations
Vercel edge logs show request arrival then 413 returned by the platform edge, not by user code. No explicit content-length validation performed in app. Some successful uploads appear when client sets Content-Length header; chunked Transfer-Encoding cases are more likely to fail.
Already attempted
Verified Next.js config includes sizeLimit, redeployed, attempted to parse raw request body in middleware, implemented a multipart streaming endpoint as experiment, tested direct curl requests with explicit Content-Length — large requests accepted consistently only when sent with Content-Length in many cases.
Question
Why are large JSON uploads intermittently rejected with 413 in production even though sizeLimit is configured, and how can I reliably accept large payloads without moving upload storage off-platform?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Web Development32% match
Next.js serverless API on Vercel returns intermittent 504s for long upstream requests when HTTP keep-alive sockets are exhausted
Open0 answers - Web Development28% match
Next.js API behind Vercel Edge intermittently returns 403 due to cached edge responses dropping Cookie headers
Open0 answers - Web Development25% match
NGINX HTTP/2 proxy drops chunked Transfer-Encoding uploads to Next.js API routes — request body never reaches Node
Solved1 answer - Networking23% match
Dual‑WAN Edge Router Sends HTTPS Traffic Out Slower Link Despite Healthy Primary — Large TCP Transfers Stall
Open0 answers - Web Development21% match
Next.js serverless API returns 502 for large Transfer-Encoding: chunked uploads only when behind NGINX reverse proxy
Open0 answers