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.
H30012vite-doctor/h3responsewarnSuggestion

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.

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 })
})
Copyright © 2026