[英]Nuxt auth with a guest and auth middleware redirects an authenticated user on refresh to the wrong page
[英]Why user is not authenticated after google authorization in nuxt-auth-next?
我在我的 nuxt 应用程序中为 nuxt-auth-next 使用以下配置
nuxt.config.js
auth: {
strategies:{
google: {
clientId: "my_client_id.apps.googleusercontent.com",
redirectUri: `http://localhost:3000/apps`,
codeChallengeMethod: '',
scope: ['profile', 'email'],
responseType: 'token id_token'
}
},
redirect: {
login: '/login',
logout: false,
home: '/apps',
callback: false
}
},
router: {
middleware: ['auth']
}
这是我的login.vue
文件
<template>
<div>
<div>
<template>
<b-button @click="loginClicked()">Login with Google</b-button>
</template>
</div>
</div>
</template>
<script>
export default {
methods: {
async loginClicked() {
try {
await this.$auth.loginWith('google');
} catch (err) {
console.log("login error: " + err);
}
}
}
}
</script>
当我从登录页面按“使用 Google 登录”按钮时,它会转到 Google 身份验证页面,成功通过身份验证,转到 localhost:3000/apps 页面(我的重定向 URL),然后立即返回 localhost:3000/login - 和这个。 $auth.loggedIn 是假的。
我已经访问过https://github.com/nuxt-community/auth-module/issues/1127 ,但这没有帮助。 我错过了什么吗?
"@nuxtjs/auth-next": "5.0.0-1624817847.21691f1",
"nuxt": "^2.15.8"
如本页所述, auth-next
aka v5 仍处于测试阶段,您可能会遇到一些错误,即使它在功能方面更加丰富。
如果您对 Nuxt 模块随 v4 提供的内容感到满意,那么坚持使用它可能是一个更稳定的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.