Skip to content

How to check domain of last page when document.referrer is not available #3920

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

Closed
HerrNamenlos123 opened this issue Mar 1, 2025 · 1 comment

Comments

@HerrNamenlos123
Copy link

If i understand #3892 and #883 correctly, document.referrer is not supposed to be used with the Vue 3 Router.

What I am trying to achieve is to implement a custom back button, that checks the previously visited page from the Router History, and if the page is within my own application (same domain name), it should use router.back() and do it, but if the page is outside of mine (other domain or nonexistent, user entered url directly, etc...) then it should navigate to the homepage instead.

To do that, I need to know the domain of the last history entry. The router itself only provides the part AFTER the domain and document.referrer is always empty.

I also cannot manually store the last page because it would either only work once, or if it was a stack, it would get messed up when using router.back().

How am i supposed to achieve this goal?

@HerrNamenlos123
Copy link
Author

I just realized this was the wrong repository, as I am using Vue 3.
I opened a discussion in the Vue 3 Repo: vuejs/router#2469

Sorry for the noise here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants