【问题标题】:Nuxt-Auth (Google Provider): JWT received from strapi backend but No redirection to home pageNuxt-Auth(Google Provider):从strapi后端收到JWT,但没有重定向到主页
【发布时间】:2021-09-27 10:28:38
【问题描述】:

我正在构建一个基于 NuxtJS 的前端应用程序,并以 Strapi 作为后端。我已经在 Strapi 上配置了 google 提供程序。但是,一旦将它与前端连接起来,我就会遇到问题。 基本上,登录后,它会将我重定向到带有令牌的前端 URL,而不是直接到主页。

下面是我的 nuxt-config 代码:

auth: {
  strategies:{
    google: {
      clientId: 'google_client_id',
      codeChallengeMethod:'',
      endpoints: {
        authorization: 'https://strapi.backend.com/connect/google',
        token: 'https://strapi.backend.com/token',
        userInfo: 'https://strapi.backend.com/users/me'
      },
      token: {
        property: 'id_token',
        type: 'jwt',
        maxAge: 1800
      },
      responseType: 'token',
      grantType: 'authorization_code',
    }
  }
}

登录.vue 代码

export default {
  methods: {
    async google(){
    await this.$auth.loginWith('google')
  }
}

如果我遗漏了什么,请告诉我。

【问题讨论】:

    标签: nuxt.js strapi nuxt-auth


    【解决方案1】:

    您是否尝试过使用redirect 键?

    auth: {
      redirect: {
        home: '/',
      },
      ...
    }
    

    【讨论】:

      猜你喜欢
      • 2019-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 2021-06-23
      相关资源
      最近更新 更多