1👍
✅
When the user is not logged in, the router guard is redirecting to path: '/', query: {redirect: to.fullPath}
. At this point to.fullPath == "/dashboard"
.
The forwardslash '/'
character is not a valid query character, so vue-router converts this to the encoded version %2F
using encodeURIComponent("/dashboard")
.
When the user logs in, you can get the redirect parameter from $route.query.redirect
and it will be automatically decoded back into /dashboard
.
Alternatively, since all of your routes have names, instead of setting the redirect
parameter to to.fullPath
you could use set it to to.name
, then when the user logs in you can redirect to the route by name.
Source:stackexchange.com