Docs API Utils

setResponseStatus

setResponseStatus sets the statusCode (and optionally the statusMessage) of the response.

Nuxt provides composables and utilities for first-class server-side-rendering support.

setResponseStatus sets the statusCode (and optionally the statusMessage) of the response.

const event = useRequestEvent()// Set the status code to 404 for a custom 404 pagesetResponseStatus(event, 404)// Set the status message as wellsetResponseStatus(event, 404, 'Page Not Found')
In the browser, setResponseStatus will have no effect.
Read more in Docs > Getting Started > Error Handling.