简体   繁体   中英

Firefox with Vue.js redirecting to a wrong route

I need to jump to one of my page in a Vue.js project from another website to do the login, and then jumps back with token.
But now I encountered an issue with redirecting on Firefox.

This was the link I was trying to go:
https://www.host.com/admin/#/LoginPage?loginrul=selectportal.html%23%2Fsphome&type=login
But this is where Firefox actually taken me to:
https://www.host.cn/admin/#/sphome

What confuses me is that this issue appears only on Firefox , I will not encounter it both on Chrome nor IE.
It also does not appear when I enter the URL manually.

Any help will be appreciated.

导航消息与 url 不匹配

The problem is that Firefox selects the last decoded part of your url. %23%2F is the same as #/ , while %23 is # and %2F / . So for Firefox not /LoginPage?loginrul=selectportal.html%23%2Fsphome&type=login is the url, instead it´s #/sphome&type=login . That this part is decoded doesn´t mean it doesn´t get interpreted by a browser.

Maybe Chrome and IE using the first hash as their entry. But that was just lucky. You need to get rid of your hash, you can achieve this by adding this to your router:

const router = new VueRouter({
  mode: 'history'
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM