H3 · H30012
Set the status on the Response you return
Flags a status set through event.res.status or setResponseStatus() in a handler that returns a Response.
h3/response/no-prepared-status-with-responsesrc/rule-packs/h3/rules/no-prepared-status-with-response.ts Upstream docs Run this rule
pnpm vite-doctor . --rules h3/response/no-prepared-status-with-response
Why it matters
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.
Recommended fix
Pass the status to the Response, such as new Response(body, { status: 201 }), or return a plain value instead.
Useful links
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 })
})