Hello almighty community!
I have a little problem with Vue.js 3. In the router, I'm unable to define that any unknown route should be redirected to "/".
const routes = [
{
path: "/",
name: "Home",
component: Home,
},
{
path: "/*",
redirect: "/",
}
]
Here, I have tested the redirect: "/" works, but path: "/*" is not working. Path "/" works only for domain.com/... I have also tested path: "*" but I get this error:
"Uncaught Error: Route "" should be "/"."
How do you do a 404 redirect in the latest Vue.js3?
In Vue router 4 which is compatible with Vue 3 you can Catch all / 404 Not found Route as follows:
LIVE DEMO