Skip to content

document.referrer is empty when navigating via links to another view. #3892

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
dev-samples opened this issue Jun 21, 2024 · 1 comment
Closed

Comments

@dev-samples
Copy link

dev-samples commented Jun 21, 2024

Version

3.5.1

Reproduction link

github.com

Steps to reproduce

Navigate from this view:

<template>
  <div>
    <div class="about">
      <h1>This is an about page</h1>
    </div>
    <nav>
      <router-link to="/another">Another</router-link>
    </nav>
    <router-view />
  </div>
</template>

to this view:

<template>
  <div class="another">
    <h1>This is another page</h1>
    <!--     <p>Coming from (referrer): {{ myvar }}</p> -->
  </div>
</template>

<script>
export default {
  name: "AnotherView",
  data() {
    return {
      myvar: "",
    };
  },
  mounted() {
    console.log("document.referrer", document.referrer);
    this.myvar = document.referrer;

    // Accessing the document content and referrer
    this.documentContent = document.documentElement.outerHTML;
    this.documentReferrer = document.referrer;

    console.log(" - - Document Referrer:", this.documentReferrer);
  },
};
</script>

What is expected?

That it prints the value/path of the previous (/about) route in the target route (/another)

What is actually happening?

It just print empty


Upgrading to a later version of vuejs is not an option at the moment. Did read:
#883

but not sure if it what I am hitting here.

@posva
Copy link
Member

posva commented Jun 24, 2024

This is expected behavior in SPAs using history.pushState().
I recommend you using the Discord server if you need help with what you are trying to do regarding the document.referrer property

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