Axel Stone
Axel Stone

Reputation: 1580

Cannot read query params becouse vue.js is adding #/ to the end of url

I have a one page app in vueJS:

let router = new VueRouter({
  routes: [
    { path: '/',  component: Dis13HomeComponent },
    { path: '**', component: Dis13HomeComponent }
  ]
});

In main component in mounted() im getting the url param like this:

this.$route.query.token;

But if I open http://www.myapp.com/app.html?token=s56ds6d5d56f6ef6e it does not read the token parameter, becouse vue is adding #/ to the end of url so it looks like http://www.myapp.com/app.html?token=s56ds6d5d56f6ef6e#/

If I open this format of url: http://www.myapp.com/app.html#/?token=s56ds6d5d56f6ef6e then it works, but this path is forbidden on server.

How could I read the token parameter?

Upvotes: 0

Views: 492

Answers (1)

V. Sambor
V. Sambor

Reputation: 13379

Make your router to work with history mode and you will not have the '#' anymore.

const router = new VueRouter({
  mode: 'history',     // <------------- HERE
  routes: [
    { path: '/',  component: Dis13HomeComponent },
    { path: '**', component: Dis13HomeComponent }
  ]
});

Upvotes: 1

Related Questions