mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
fix: don't display 404 page if no pages/
This commit is contained in:
parent
b4251b1389
commit
d63b28303e
@ -1,2 +1,2 @@
|
|||||||
// TODO: Use webpack-virtual-modules
|
// TODO: Use webpack-virtual-modules
|
||||||
export default <%= app.templates.routes %>
|
export default <%= app.templates.routes || '[]' %>
|
||||||
|
@ -43,18 +43,20 @@ export async function createApp (
|
|||||||
if (app.pages) {
|
if (app.pages) {
|
||||||
app.routes.push(...(await resolvePagesRoutes(builder, app)))
|
app.routes.push(...(await resolvePagesRoutes(builder, app)))
|
||||||
}
|
}
|
||||||
// Add 404 page is not added
|
if (app.routes.length) {
|
||||||
const page404 = app.routes.find(route => route.name === '404')
|
// Add 404 page is not added
|
||||||
if (!page404) {
|
const page404 = app.routes.find(route => route.name === '404')
|
||||||
app.routes.push({
|
if (!page404) {
|
||||||
name: '404',
|
app.routes.push({
|
||||||
path: '/:catchAll(.*)*',
|
name: '404',
|
||||||
file: resolve(nuxt.options.appDir, 'pages/404.vue'),
|
path: '/:catchAll(.*)*',
|
||||||
children: []
|
file: resolve(nuxt.options.appDir, 'pages/404.vue'),
|
||||||
})
|
children: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// TODO: Hook to extend routes
|
||||||
|
app.templates.routes = serializeRoutes(app.routes)
|
||||||
}
|
}
|
||||||
// TODO: Hook to extend routes
|
|
||||||
app.templates.routes = serializeRoutes(app.routes)
|
|
||||||
|
|
||||||
// Fallback app.main
|
// Fallback app.main
|
||||||
if (!app.main && app.routes.length) {
|
if (!app.main && app.routes.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user