mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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>
|
<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
|
## Nested Routes
|
||||||
|
|
||||||
It is possible to display [nested routes](https://next.router.vuejs.org/guide/essentials/nested-routes.html) with `<NuxtPage>`.
|
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,
|
statusCode: 404,
|
||||||
statusMessage: `Page not found: ${to.fullPath}`
|
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