H3 · Responses
vite-doctor/h3responsewarnSuggestion
Why it happens
H3 v2 applies a prepared event.res.status only to plain return values. A returned Response keeps its own status, so the prepared status is silently ignored and the client gets 200.
Fix
Pass the status to the Response, such as new Response(body, { status: 201 }), or return a plain value instead.
Example
Set the status on the Response
Before
export default defineHandler((event) => {
event.res.status = 201
return new Response("created")
})
After
export default defineHandler(() => {
return new Response("created", { status: 201 })
})
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/response/no-prepared-status-with-response