Open Frank-Z20 opened 2 years ago
We have the same problem over here, I made a small hack that works perfectly.
Create a small route middleware file and place this direct after the auth middleware in the nuxt.config.js
{
route: {
middleware: [
'auth', 'auth-validation'
]
},
...
}
// middleware/auth-validation.js
export default async function ({ $auth, route }) {
// current token is invalid but the user is still loggedIn
if(!$auth.strategy.token.status().valid() &&
!$auth.strategy.refreshToken.status().valid() &&
$auth.loggedIn
) {
// do not remove loggedIn when we authenticate
if(!["login", "callback"].includes(route.name)) {
$auth.setUser(false);
}
}
}
I can loggin successfully and the loggedin is true, but when i loggout the loggedin is still true. This only happened on server. If I run npm dev it has no problem.