mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
docs: add warning about redirect check (#20680)
This commit is contained in:
parent
05a8c2d955
commit
4ac4dfda15
@ -30,6 +30,9 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
||||
if (to.params.id === '1') {
|
||||
return abortNavigation()
|
||||
}
|
||||
// In a real app you would probably not redirect every route to `/`
|
||||
// however it is important to check `to.path` before redirecting or you
|
||||
// might get an infinite redirect loop
|
||||
if (to.path !== '/') {
|
||||
return navigateTo('/')
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ You can pass the error as a string:
|
||||
|
||||
```ts [middleware/auth.ts]
|
||||
export default defineNuxtRouteMiddleware((to, from) => {
|
||||
const auth = useState('auth')
|
||||
const user = useState('user')
|
||||
|
||||
if (!user.value.isAuthorized) {
|
||||
return abortNavigation('Insufficient permissions.')
|
||||
|
Loading…
Reference in New Issue
Block a user