VueJS: Redirect Unmatched Routes To 404
Like any other website if the router can not find the URL you're navigating to then you need to display a 404 page to your user for them to know this page doesn't exist anymore.
You can redirect any unmatched route to a 404 page in Vue by add the following code snippet to the bottom of your route object.
This will match on all URLs, and display the component for a 404.vue component. This is important that it goes at the bottom of your defined routes, as Vue will go through your URLs and display the . . .
Subscribe To Newsletter
Get weekly updates to your email