I am currently in the process of converting a Vue project into Nuxt.
I have successfully implemented a navigation guard in the app using router.beforeEach()
.
Upon accessing the base URL localhost:3000
, I encounter the image below:
https://i.sstatic.net/CuoVE.png and here is the corresponding code block that manages that path:
if (to.path == '/') {
switch (auth.getRole()) {
case '1':
next({
path: '/route_1'
})
break
case '2':
next({
path: '/route_2'
})
break
default:
next({
path: '/route_3'
})
break
}
}
However, when I directly enter the address localhost:3000/login
in the URL bar, the page renders properly.
EDIT:
Here is my pages folder structure:
https://i.sstatic.net/5D8Yu.png
Any assistance would be greatly appreciated. Thank you!