H3 · Request body
vite-doctor/h3bodyerrorSuggestion
Why it happens
H3 v2 uses the Web Request stream. If a body is present and the first read consumes it, a second read can fail and the original stream can no longer be forwarded by a proxy.
Fix
Read the body once and reuse it, or read from a clone before forwarding the original stream to a proxy.
Example
Read the body once
Before
export default defineHandler(async (event) => {
await audit(await readBody(event))
return save(await readBody(event))
})
After
export default defineHandler(async (event) => {
const body = await readBody(event)
await audit(body)
return save(body)
})
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm vite-doctor . --rules h3/body/no-double-body-read