vuejs2 - 未登录时 Nuxt auth 重定向不起作用
问题描述
我正在使用 Nuxt 和 Auth 模块。我试图在用户未登录时将其重定向到登录页面。
nuxt.config.js:
auth: {
redirect: {
login: '/account/inloggen',
logout: '/account/uitloggen',
callback: '/account/aanmelden',
home: '/'
},
strategies: {
google: {
access_token_endpoint: '****/social?identityProvider=Google',
access_type: 'offline',
client_id: '*****.apps.googleusercontent.com',
grant_type: 'authorization_code',
redirect_uri: 'http://localhost:3000/account/aanmelden',
response_type: 'code',
token_key: 'jwt',
userinfo_endpoint: '****/user/profile'
}
},
cookie: {
options: {
maxAge: 86400
}
}
// localStorage: false
},
我正在阅读文档
login:如果需要登录,用户将被重定向到此路径。
但我找不到要求用户登录的位置/方式。
重定向确实有效,当home: '/'
用户登录时,他们被重定向到应用程序的根目录。
解决方案
在Github上找到我的答案
我也遇到过这个问题。我的错误是在我的登录页面上设置了 auth: false 。如果你有它,只需将其删除。
<script>
export default {
auth: false
}
</script>
推荐阅读
- laravel - Laravel:排队的作业如何在失败时将自己移动到 failed_jobs?
- python - 在python中基于opencv图像创建rtsp流
- java - ArrayIndexOutOfBoundsException 与错误索引无关
- javascript - 如何更改 .css 类属性 - 背景:每个项目的 url('') javascript / typescript
- python - Python 书写字符 Ä 而不是关闭 " 和 ' 发现但我无法理解请尝试解释一下
- r - 从 R 到 scala:导入库
- php - 如何在 Laravel 5.6 中正确使用可选路由参数?
- android - 当文本输入聚焦时,在文本输入和键盘中保持小间隙
- jenkins - 使用 Jenkins Pipeline REST API 获取构建步骤
- sql - 如果没有错误,请执行 sql 请求/检索数据