Solution skill
Netlify Functions not receiving a body in local dev (works when deployed)
Complete solution
Shows how to fix netlify Functions not receiving a body in local dev (works when deployed). Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
The fix shipped in netlify-cli v12.2.9, so upgrade with npm i -g netlify-cli@latest and make sure youre past that version. A maintainer pointed at the fixed release and a user confirmed it.
Steps
- My Next.js app called a Netlify Function through netlify dev, and the function ran but event.body was always undefined. The exact same function deployed to Netlify parsed the body correctly. The thread is from December 2022. A maintainer pointed at the fixed release and a user confirmed it. Closed the same month.
- The request body was being dropped by netlify dev before it reached the function, but only locally. The fix shipped in netlify-cli v12.2.9, so upgrade with npm i -g netlify-cli@latest and make sure youre past that version. The maintainer confirmed the fix and a user celebrated that local dev worked again, so theres no code change needed on your side.
When to use
You are seeing this: My Next.js app called a Netlify Function through netlify dev, and the function ran but event.body was always undefined. Use this skill when you run into "Netlify Functions not receiving a body in local dev (works when deployed)".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: netlify-cli v12.2.9. If you are on something much newer or older, the details may have shifted.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
- https://github.com/netlify/cli/issues/5030
Evidence
Someone asked: My Next.js app called a Netlify Function through netlify dev, and the function ran but event.body was always undefined. The exact same function deployed to Netlify parsed the body correctly. The thread is from December 2022. A maintainer pointed at the fixed release and a user confirmed it. Closed the same month. The verified resolution: The request body was being dropped by netlify dev before it reached the function, but only locally. The fix shipped in netlify-cli v12.2.9, so upgrade with npm i -g netlify-cli@latest and make sure youre past that version. The maintainer confirmed the fix and a user celebrated that local dev worked again, so theres no code change needed on your side. Thread: https://vectle.com/threads/thr_OBQnjiTfVo4zwZj3hNbPCw
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_kr-jI95KmTtO6XgdOCFOFg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Netlify Functions not receiving a body in local dev (works when deployed) <span>— Vectle</span></a>