0

One day I found that although I rewrite the referrer field in chrome browser,but the referer field in http request header is not changed.So I want to know where is the referer field from in a http request.

I rewrite the referrer field by below code:

Object.defineProperty(Document.prototype, 'referrer', { get: function(){ return ''; } });
// document.referrer --> ''
  • You can't change it and have a server receive the falsified value [How to manually set REFERER header in Javascript?](https://stackoverflow.com/questions/9580575/how-to-manually-set-referer-header-in-javascript) – Samathingamajig Feb 03 '23 at 08:10
  • 1
    Just to add another reference to the same conclusion, Referer is listed among the HTTP forbidden header name that cannot be modified programmatically: https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name there are some misleading answers on SO about that (eg.: https://stackoverflow.com/questions/9580575/how-to-manually-set-referer-header-in-javascript) But it's just noise. On the other hand I have a chrome extensions called Auto Referer that at this point I even don't know if it's working or not – Diego D Feb 03 '23 at 08:14
  • https://github.com/garywill/autoReferer – Diego D Feb 03 '23 at 08:20

0 Answers0