How to add a Referrer-Policy header
When someone clicks a link from your site to another, the browser tells that other site which page they came from. Sometimes the address contains private things, such as a reset token, an order number or an internal path. Referrer-Policy sets how much is shared.
Updated 2026-10-23
Why it matters
- It stops private parts of your URLs leaking to other sites, including the analytics and ad scripts you embed.
- strict-origin-when-cross-origin is a sensible default: other sites see only your domain, and nothing at all if the link goes from HTTPS to HTTP.
How to fix it
- Add this header to every response from example.com.
Pick what your site runs on. Replace example.com with your own domain where it appears.
After you deploy, re-check the site. A CDN or the browser cache can keep serving the old headers for a few minutes.
nginx
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
Apache
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Caddy
header {
Referrer-Policy "strict-origin-when-cross-origin"
}Cloudflare
Referrer-Policy: strict-origin-when-cross-origin
Vercel
{
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "Referrer-Policy",
"value": "strict-origin-when-cross-origin"
}
]
}
]
}Netlify
/* Referrer-Policy: strict-origin-when-cross-origin
Next.js
const nextConfig = {
async headers() {
return [
{
source: "/(.*)",
headers: [
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
],
},
];
},
};
export default nextConfig;Express
app.use((req, res, next) => {
res.setHeader("Referrer-Policy", "strict-origin-when-cross-origin");
next();
});Common mistakes
- Choosing no-referrer when your own analytics or affiliate tracking relies on the referrer.
- Putting secrets in URLs at all. The header limits the leak, but a token in a URL is still better moved to a header or a form body.
Check that it worked
Run your domain through the free security headers checker. It takes a few seconds, needs no account, and shows anything still missing.
Open the security headers checkerQuestions
- Which value should I use?
- strict-origin-when-cross-origin. It is also what current browsers do by default, so adding it explicitly mostly makes the behaviour reliable across browsers.
Related guides
Don't want to check by hand? Upzy watches your site around the clock and tells you when a header, certificate or email record slips. Start free.