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

Base tag in head not ignored if parameter to createWebHashHistory is passed #685

Closed
vitchioto opened this issue Jan 3, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@vitchioto
Copy link

Version

4.0.2

Reproduction link

https://github.com/vitchioto/vue3-test

Steps to reproduce

  1. Build the application
  2. Deploy it to a sub-folder of a domain (might need to update publicPath in vue.config.js)
  3. Open the subfolder in a browser

What is expected?

Path in the address bar stays as it is (only with added #/ in the end of the address).

You can see it here: https://test.vladovic.sk/router/

What is actually happening?

Path in address bar and urls of router links are changed to root (value of base tag)

You can see it here: https://test.vladovic.sk/router-bug/


The only difference between those 2 pages is this line:

https://github.com/vitchioto/vue3-test/blob/master/public/index.html#L9

Although, according to documentation, base tag in head should be ignored if parameter is passed to createWebHashHistory (https://next.router.vuejs.org/api/#createwebhashhistory).

@posva posva closed this as completed in bd84d0e Jan 4, 2021
@posva
Copy link
Member

posva commented Jan 4, 2021

Updated the documentation: the base tag needs to have an appropriate value because it's taken into account by history.pushState. In your case, it should have /router-bug/

@vitchioto
Copy link
Author

Hi @posva, thanks for your reply :)

do you know, if there is any workaround?

the problem I have is, that I am just "injecting" Vue app into existing page handled by our corporate CMS. So I am not touching header / footer, only main part in between them. Hence, updating value of base tag is not an option for me :/

when I use Vue 2 with (older version of) router, it works as I expected, though...

demo page: https://test.vladovic.sk/router-v2/
git repo: https://github.com/vitchioto/vue2-test

thanks in advance :)

@posva
Copy link
Member

posva commented Jan 4, 2021

It used to work because the hash history implementation was different but now that it relies on the HTML5 history to provide many more features.

I realized there is a way to support by checking the existence of the <base> element and pushed a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants