The Referrer-Policy header controls how much information about the URL of the referring page is shared when navigating to another website. By limiting or anonymising referrer data, this header helps protect user privacy and prevent sensitive information leaks.
.htaccess file if you use one).no-referrer with the policy that fits your needs: Header set Referrer-Policy "no-referrer"/etc/nginx/sites-available/your-site).server block, replacing no-referrer with the policy that fits your needs: add_header Referrer-Policy "no-referrer";sudo systemctl restart nginxheader("Referrer-Policy: no-referrer"); Use a middleware like helmet to set the header automatically:
const helmet = require('helmet');
app.use(helmet.referrerPolicy({ policy: 'no-referrer' })); Or set it manually:
app.use((req, res, next) => {
res.setHeader('Referrer-Policy', 'no-referrer');
next();
}); from flask import Flask, Response
app = Flask(__name__)
@app.after_request
def set_headers(response):
response.headers['Referrer-Policy'] = 'no-referrer'
return response After setting the header, test your website to ensure itโs working:
Referrer-Policy header with the correct value.Setting this header helps protect user privacy by controlling the information shared in referrer URLs, reducing the risk of leaking sensitive data to third-party websites or attackers.