Referrer Policy

·

2 min read

What Is 'Referrer'?

It is a site (or page) that connects another site using things like 'a' tag or 'fetch' api.

What Is 'Referrer Policy'?

In HTTP(S), information about referrer can be shown to who get the requests. In this situation, referrers can decide how much of their information to be shown and 'Referrer Policy' is the choices.

Kinds of Referrer Policy

You can check them in the below link.

Standards in Referrer Polices

Whether the Environment Is Secure

  1. HTTPS to HTTP: If the referrer is in HTTPS and the referent is in HTTP, the referrer may not want to give its information.

  2. origin: If the referrer and the referent have different origins, the referrer may not want to give its information.

How Much Information Will Be Shown

The refferer can choose nothing to be shown, only origin to be shown and full URL to be shown.

How to Check the Information as a Referrer

In dev tools, headers of HTTP can be checked.

In 'General' part, there is the policy.

In 'Request' part, there is the referrer. In this part, there is only one 'r', so 'referer'.

How to Designate

Using an Attribute

<a href="http://example.org" referrerpolicy="no-referrer-when-downgrade">HTTP</a>

in fetch API

(async () => {
  const response = await fetch('https://jsonplaceholder.typicode.com/posts', {
    // 'P' is the capital letter.
    referrerPolicy: 'origin',
  });
  const data = await response.json();
  console.log(data);
})();