Search code examples
axiosnuxt.js

How to redirect if succes login with Google in Nuxt js


here I try to log in using google at nuxt.js, but when I log in with my Google account, the page doesn't move

has anyone experienced the same thing?

I hope someone provides an example of the code. thank you

enter image description here

this.my code login.vue

 async loginGoogle() {
    try {
      let response = await this.$auth.loginWith('google', {})
      console.log(response)
    } catch (err) {
      console.log(err)
    }
  }

this my code nuxt.config.js

 google: {
    client_id: 'xxxxxxxxx.apps.googleusercontent.com',
    redirect_uri: 'http://localhost:3000',
  },

Solution

  • I have take a look at https://auth.nuxtjs.org/api/options.html#redirect

    It looks different they use auth in ther nuxt.config.js

    auth: {
      redirect: {
        login: '/login',
        logout: '/',
        callback: '/login',
        home: '/'
      }
    }