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

Routes ending with an optional slug are not working anymore #1242

Closed
1 task done
arikw opened this issue Jul 22, 2021 · 2 comments · Fixed by #1243
Closed
1 task done

Routes ending with an optional slug are not working anymore #1242

arikw opened this issue Jul 22, 2021 · 2 comments · Fixed by #1243
Labels

Comments

@arikw
Copy link

arikw commented Jul 22, 2021

Version

nuxt-i18n: 6.27.3
nuxt: 2.15.7

Nuxt configuration

mode:

  • universal

Nuxt-i18n configuration

i18n: {
    strategy: 'prefix',
    lazy: true,
    detectBrowserLanguage: false
}

Steps to reproduce

nuxt.config.js

i18n: {
    strategy: 'prefix',
    lazy: true,
    detectBrowserLanguage: false
},
router: {
    trailingSlash: true
}
modules: [
    '~/modules/routes'
]

modules/routes.js

export default async function asyncModule() {
  this.extendRoutes(function extendRoutes(routes, resolve) {
    routes.push({
      name: 'product-page',
      path: `/:product(game|software)/:uid/:slug?`, // <-- notice the optional slug used with "?"
      component: resolve(__dirname, 'pages/product.vue')
    });
  }
}

What is Expected?

  1. A route with a path of /es-ES/:product(game|software)/:uid/:slug?/ should be created and listed in $nuxt.$router.options.routes
  2. Browsing to /game/98f76a/cod/ should return the correct page as worked in [email protected]

What is actually happening?

  1. A route with a path of /es-ES/:product(game|software)/:uid/:slug/? gets created (Notice the ? got moved to the end of the path) and listed in $nuxt.$router.options.routes.
  2. Browsing to /game/98f76a/cod/ returns a 404 error page.
@arikw arikw added the bug 🐛 label Jul 22, 2021
@divine
Copy link

divine commented Jul 22, 2021

Hello,

A simple reproduction? Might be related #1001.

Thanks!

@rchl
Copy link
Collaborator

rchl commented Jul 22, 2021

I can reproduce. It's caused by #1214

rchl added a commit that referenced this issue Jul 22, 2021
Don't use ufo on Vue Router route definitions as those are not
a normal paths, or not always at least.

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

Successfully merging a pull request may close this issue.

3 participants