Redirect to previous url after login in nuxt.js
·
Answer a question
I basically want to redirect to the previous url when a user has successfully logged in.
I redirect to the login page with the previous url such as /login?redirect=/page1/page2.
And I want when a user authenticates to be redirected back to that url. I am using the auth-module here: https://auth.nuxtjs.org/
How I login the user.
methods: {
async submit() {
await this.$auth.loginWith('local', {
data: this.form
})
}
}
The only thing that I could found in the docs is this: https://auth.nuxtjs.org/getting-started/options#redirect
which however only redirects to a specific page instead of the previous page in the query.
Any ideas on how to achieve this?
Answers
You Can Do This
this.$router.back()
And its go back to the last route.
Programmatic Navigation | Vue Router https://router.vuejs.org/guide/essentials/navigation.html
Thanks.
更多推荐

所有评论(0)