refactor: use middleware to handle redirection
This commit is contained in:
parent
a17d3276d3
commit
0dac7b9785
3 changed files with 15 additions and 13 deletions
8
middleware/auth.ts
Normal file
8
middleware/auth.ts
Normal file
|
@ -0,0 +1,8 @@
|
|||
export default defineNuxtRouteMiddleware((from) => {
|
||||
const token = useCookie('nuxtodon-token')
|
||||
|
||||
if (!token.value)
|
||||
return navigateTo('/public')
|
||||
else if (from.path === '/')
|
||||
return navigateTo('/home')
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue