From 557c40c97f410175cec439524b215308471b965d Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Fri, 20 May 2022 11:09:41 +0200 Subject: [PATCH] docs(middleware): add `navigateTo` options (#5044) Co-authored-by: Daniel Roe --- docs/content/2.guide/3.directory-structure/7.middleware.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/content/2.guide/3.directory-structure/7.middleware.md b/docs/content/2.guide/3.directory-structure/7.middleware.md index 0e78a9aefa..e09e336f7a 100644 --- a/docs/content/2.guide/3.directory-structure/7.middleware.md +++ b/docs/content/2.guide/3.directory-structure/7.middleware.md @@ -35,13 +35,14 @@ export default defineNuxtRouteMiddleware((to, from) => { Nuxt provides two globally available helpers that can be returned directly from the middleware: -1. `navigateTo (route: string | Route)` - Redirects to the given route, within plugins or middleware. It can also be called directly on the client side to perform page navigation. +1. `navigateTo (route: string | Route, options: { redirectCode: number, replace: boolean )` - Redirects to the given route, within plugins or middleware. It can also be called directly to perform page navigation. 2. `abortNavigation (err?: string | Error)` - Aborts the navigation, with an optional error message. -Unlike, navigation guards in [the vue-router docs](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards), a third `next()` argument is not passed, and redirects or route cancellation is handled by returning a value from the middleware. Possible return values are: +Unlike navigation guards in [the vue-router docs](https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards), a third `next()` argument is not passed, and redirects or route cancellation is handled by returning a value from the middleware. Possible return values are: * nothing - does not block navigation and will move to the next middleware function, if any, or complete the route navigation * `navigateTo('/')` or `navigateTo({ path: '/' })` - redirects to the given path +* `navigateTo('/', { redirectCode: 302 })` - Redirects to the given path and will set the redirect code if the redirect happens on the server side (default: 301) * `abortNavigation()` - stops the current navigation * `abortNavigation(error)` - rejects the current navigation with an error