title: VueJs get referral URL that called a specific route
body: <p>I'm trying to get the <strong>referral URL</strong> from where a specific route from my VueJS app was called.</p>
  <p>The flow is:</p>
  <ol>
  <li><em>Route1</em> redirects to (outside) <em>URL1</em> with a <em>returnURL</em></li>
  <li>(outside) <em>URL1</em> performs some actions and returns to <em>returnURL</em></li>
  <li><em>ReturnUrl</em> matches <em>Route2</em> and shows a view <strong>(only if it comes from <em>URL1</em>)</strong></li>
  </ol>
  <p>I've tried with:</p>
  <pre><code>router.beforeEach((to, from, next) =&gt; {
    console.log(to)
    console.log(from)
    next()
  })
  </code></pre>
  <p>But the <code>from</code> url is always <code>/</code>. Also I tried with:</p>
  <pre><code>this.$route.query
  </code></pre>
  <p>(from <a href="https://stackoverflow.com/questions/48265620/how-to-get-http-refere-in-vuejs">How to get http refere in vuejs?</a>)</p>
  <p>And with plain JS with something like:</p>
  <pre><code>var referrer = document.referrer;
  </code></pre>
  <p>Finally I tried with this <a href="https://www.npmjs.com/package/@tozd/vue-router-referer" rel="nofollow noreferrer">plugin</a> without success.</p>
  <p>The problem is that I don't have any clue if the user called directly the <code>returnUrl</code> (forbidden) or it's a call from the outside service <code>URL1</code> (valid).</p>
  <p>It's this possible?</p>
  <p>I checked:
  <a href="https://stackoverflow.com/questions/6856697/can-i-get-the-referrer">Can I get the referrer?</a></p>