I have a simple image preview that, when clicked, takes you to a full size image:
<html>
<head>
<meta name="referrer" content="origin">
</head>
<body>
<a href="/myimage.jpg">
<img src="/myimage.jpg" title="my image" border="0" />
</a>
</body>
</html>
The problem: in addition to the request for the image, the browser will also request the favicon.ico. The request headers for the image is: Referer: https://example.com/ (as expected). However, for the request for the favicon.ico file, this header is the full url of the referring page: Referer: https://example.com/where-I-was.
How do I set the Referer header for the favicon.ico request to simply the origin? I don't want it the full url to show in my nginx logs. Thx!
Option 1
Use the
referrerpolicyHTML attribute on the link tag - see docs on MDN.Option 2
Use the
webRequestAPI to rewrite the Referer header - see the MDN page on it here. Simply set the header to whatever you want it to be - seems like you might be interested in the window.location object.Sample code - modified from the MDN page: