mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): default statusCode of navigateTo
from 301
to 302
(#5173)
Co-authored-by: pooya parsa <pyapar@gmail.com>
This commit is contained in:
parent
2114a02293
commit
fca2ed7cc5
@ -41,8 +41,10 @@ Nuxt provides two globally available helpers that can be returned directly from
|
||||
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)
|
||||
* `navigateTo('/')` or `navigateTo({ path: '/' })` - redirects to the given path and will set the redirect code to [`302` Found
|
||||
](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) if the redirect happens on the server side
|
||||
* `navigateTo('/', { redirectCode: 301 })` - redirects to the given path and will set the redirect code to [`301` Moved Permanently
|
||||
](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/301) if the redirect happens on the server side
|
||||
* `abortNavigation()` - stops the current navigation
|
||||
* `abortNavigation(error)` - rejects the current navigation with an error
|
||||
|
||||
|
@ -68,7 +68,7 @@ export const navigateTo = (to: RouteLocationRaw, options: NavigateToOptions = {}
|
||||
const nuxtApp = useNuxtApp()
|
||||
if (nuxtApp.ssrContext && nuxtApp.ssrContext.event) {
|
||||
const redirectLocation = joinURL(useRuntimeConfig().app.baseURL, router.resolve(to).fullPath || '/')
|
||||
return nuxtApp.callHook('app:redirected').then(() => sendRedirect(nuxtApp.ssrContext.event, redirectLocation, options.redirectCode || 301))
|
||||
return nuxtApp.callHook('app:redirected').then(() => sendRedirect(nuxtApp.ssrContext.event, redirectLocation, options.redirectCode || 302))
|
||||
}
|
||||
}
|
||||
// Client-side redirection using vue-router
|
||||
|
Loading…
Reference in New Issue
Block a user