Last active
April 23, 2018 07:23
-
-
Save vladimirlukyanov/7eede6db3799cfcc93575253e82a0ecd to your computer and use it in GitHub Desktop.
Nuxt.js 404 error handling | Nuxt.js 404 redirect | Nuxt.js middleware routing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add this file to /middleware | |
export default function ({params, route, redirect}) { | |
if(route.matched.length === 0) { // route is not found, redirect to homepage | |
redirect('302', '/'); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
head: { | |
title: 'Auth Routes', | |
meta: [ | |
{charset: 'utf-8'}, | |
{name: 'viewport', content: 'width=device-width, initial-scale=1'}, | |
{hid: 'description', content: 'Auth Routes example'} | |
] | |
}, | |
plugins: [], | |
build: { | |
analyze: false, | |
}, | |
loading: {color: '#41B883'}, | |
router: { | |
linkActiveClass: 'active', | |
middleware: ['404-redirect'] // important to add | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment