[Vuejs]-Using Regex in vue router path

0👍

In order to make :lang optional in your route’s path, you need to use ? modifier.
So, update your route object as follows:

{
    path: '/:lang?/products/shoes/nike',
    meta: { allowGuest: true },
    redirect: { name: 'shoes' },
}

Refer official vue-router docs for detailed info- https://router.vuejs.org/guide/essentials/route-matching-syntax.html#optional-parameters

Leave a comment