HTTPReferrerPolicy
What Is This Enum?
A string enum representing Fetch API RequestInit.referrerPolicy values. It controls how much origin information is included in the request's Referer header.
Values
| Name | Value | Description |
|---|---|---|
NO_REFERRER | 'no-referrer' | Does not send the Referer header. |
NO_REFERRER_WHEN_DOWNGRADE | 'no-referrer-when-downgrade' | Does not send the referrer when the request lowers the security level. |
ORIGIN | 'origin' | Sends only the origin. |
ORIGIN_WHEN_CROSS_ORIGIN | 'origin-when-cross-origin' | Sends the full URL for same-origin requests and only the origin for cross-origin requests. |
SAME_ORIGIN | 'same-origin' | Sends the referrer only for same-origin requests. |
STRICT_ORIGIN | 'strict-origin' | Sends the origin only when the security level is maintained. |
STRICT_ORIGIN_WHEN_CROSS_ORIGIN | 'strict-origin-when-cross-origin' | Sends the full URL for same-origin requests and only the origin for secure cross-origin requests. |
UNSAFE_URL | 'unsafe-url' | Sends the full URL whenever possible. |
Example
import { dench, HTTPReferrerPolicy } from 'dench-fetch';
const response = await dench('https://api.example.com')
.get('/resource')
.referrerPolicy(HTTPReferrerPolicy.NO_REFERRER)
.toResponse();
// RequestInit: { method: 'GET', referrerPolicy: 'no-referrer' }