[英]nuxt.js auth always redirect to login instead of allow go to a page with auth: false,
Hello I have the following configuration你好我有以下配置
nuxt.config.js
router: {
middleware: ['auth'],
}
auth: {
redirect: {
login: '/login',
logout: '/login',
home: '/',
},
strategies: {
cookie: {
options: {
httpOnly: true,
path: '/',
},
user: {
property: false,
autoFetch: false,
},
endpoints: {
login: { url: '/api/login', method: 'post' },
logout: { url: '/api/logout', method: 'post' },
},
},
},
},
and I the home component it is not necessary be logged, so I set:而我的家庭组件没有必要被记录,所以我设置:
export default {
name: 'IndexComponent',
middleware: 'auth',
auth: false,
}
but when I try to access to a / auth always redirects to /login.但是当我尝试访问 / auth 时,总是会重定向到 /login。
when I do click nothing happens and nothing is displayed in the console.当我单击时没有任何反应,控制台中也没有显示任何内容。
How can I solve this?我该如何解决这个问题?
In the documentation , it says在文档中,它说
In case of global usage, you can set auth option to false in a specific component and the middleware will ignore that route.
在全局使用的情况下,您可以在特定组件中将 auth 选项设置为 false,中间件将忽略该路由。
But by "component", they mean a .vue
component.但是“组件”是指
.vue
组件。
In our case, since we're using Nuxt it still needs to be a page (hence a route in the /pages/
directory) because this is logical from a router aspect.在我们的例子中,由于我们使用 Nuxt,它仍然需要是一个页面(因此是
/pages/
目录中的路由),因为从路由器的角度来看这是合乎逻辑的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.