Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtendRoutes/webpack/jiti do not process Vuex route.redirect... #8979

Closed
linqFR opened this issue Mar 12, 2021 · 4 comments · Fixed by #9024
Closed

ExtendRoutes/webpack/jiti do not process Vuex route.redirect... #8979

linqFR opened this issue Mar 12, 2021 · 4 comments · Fixed by #9024

Comments

@linqFR
Copy link

linqFR commented Mar 12, 2021

Versions

  • nuxt: 2.15.3

Steps to reproduce

	router:{
		trailingSlash:false,
		extendRoutes(routes,resolve){
			routes.unshift({
				name:'login',
				path:'/login',
				redirect(to,...a){
					return {name:'loginelse'}
				}
			})
		}
	}

is processed in .nuxt /router.js to:

export const routerOptions = {
  mode: 'history',
  base: '/',
  linkActiveClass: 'nuxt-link-active',
  linkExactActiveClass: 'nuxt-link-exact-active',
  scrollBehavior,
  routes: [{
    path: "/login",
    redirect: undefined,
    name: "login"
  }, {
    path: "/",
    component: _4ad08996,
    pathToRegexpOptions: {"strict":true},
    name: "index"
  }],
  fallback: false
}

What is Expected?

as described in docs : https://nuxtjs.org/docs/2.x/configuration-glossary/configuration-router#extendroutes:
The schema of the route should respect the vue-router schema. (vue-router schema)

What is actually happening?

redirect is not processed by webpack and/or jiti...

@linqFR linqFR changed the title ExtendRoutes / Webpack do not process Vuex route.redirect... ExtendRoutes/webpack/jiti do not process Vuex route.redirect... Mar 12, 2021
@zavvla
Copy link

zavvla commented Mar 21, 2021

I have this problem too... just ignore redirect...
extendRoutes(routes, resolve) { routes.push({ path: "/registration", redirect: "/registration/step-1", }); }

UPD I changed "routes.push" -> "routes.unshift", add "sortRoutes" and it worked.

@linqFR
Copy link
Author

linqFR commented Mar 22, 2021

I have this problem too... just ignore redirect...
extendRoutes(routes, resolve) { routes.push({ path: "/registration", redirect: "/registration/step-1", }); }

UPD I changed "routes.push" -> "routes.unshift", add "sortRoutes" and it worked.

redirect as a string works fine, but according to vue-router documentation, redirect could be a function either!

Copy link
Member

@linqFR Thanks for the issue. I've put a fix in but I would recommend using https://github.com/nuxt-community/router-extras-module or https://github.com/nuxt-community/router-module instead if you want to take over more control of how the router behaves in a Nuxt context.

@linqFR
Copy link
Author

linqFR commented Mar 22, 2021

@linqFR Thanks for the issue. I've put a fix in but I would recommend using https://github.com/nuxt-community/router-extras-module or https://github.com/nuxt-community/router-module instead if you want to take over more control of how the router behaves in a Nuxt context.

@danielpost actually i m using http-proxy(-middleware) options : options.pathRewrite and options.onProxyReq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants