[Vuejs]-Vue-Router with Queries (from Firebase API)

0👍

vue-router uses path-to-regexp as its path matching engine, so the query is not avaliable.

I suggest you can use dynamic redirecting,

{
  path: '/firebase/handle',
  redirect: (to) => {
    if (to.query.mode === 'verifyEmail') {
      return '/firebase/verify-email'
    } else if (to.query.mode === 'resetPassword') {
      return '/firebase/reset-password'
    } else {
      return '/'
    }
  }
},
{
  path: '/firebase/verify-email',
  name: 'VerifyEmail',
  component: VerifyEmail
},
{
  path: '/firebase/reset-password',
  name: 'ResetPassword',
  component: ResetPassword
}

so /firebase/handle?mode=verifyEmail&code=123 will redirect to /firebase/verify-email?mode=verifyEmail&code=123

full example is here

Edit Vue dymanic redirect

Leave a comment