mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): return 404 if hitting 404.vue
(#4460)
* fix(nuxt): return 404 if hitting `404.vue` * docs: add info about `pages/404.vue`
This commit is contained in:
parent
98586bcf25
commit
d0ae5851e4
@ -146,6 +146,10 @@ Navigating to `/hello/world` would render:
|
||||
<p>["hello", "world"]</p>
|
||||
```
|
||||
|
||||
::alert{type="info"}
|
||||
Nuxt also supports a custom `pages/404.vue` file which will handle all routes that are not otherwise matched (and set a 404 error code).
|
||||
::
|
||||
|
||||
## Nested Routes
|
||||
|
||||
It is possible to display [nested routes](https://next.router.vuejs.org/guide/essentials/nested-routes.html) with `<NuxtPage>`.
|
||||
|
@ -161,6 +161,8 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
statusCode: 404,
|
||||
statusMessage: `Page not found: ${to.fullPath}`
|
||||
})])
|
||||
} else if (process.server && to.matched[0].name === '404' && nuxtApp.ssrContext) {
|
||||
nuxtApp.ssrContext.res.statusCode = 404
|
||||
}
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user