Normally, using fetch from a website to send a request would include a referrer header in the request depending on the referrer-policy
On a chrome extension background script, I have tried with referrer as client and referrerPolicy as unsafe-url, origin and origin-when-cross-origin. In my manifest, I have my endpoint url in the permission but not all-urls.
fetch(url, {
method: 'POST',
mode: 'cors',
credentials: 'include',
cache: 'no-cache',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
referrer: 'client',
referrerPolicy: 'origin',
body: JSON.stringify({ params })
})
A violent resolution:
chrome.webRequest.onBeforeSendHeaders.addListener(
function(details) {
details.requestHeaders.push({name: 'Referer', value:'http://localhost/referer'});
return {requestHeaders: details.requestHeaders};
},
{urls: ["http://localhost/*"]},
["blocking", "requestHeaders"]
);
fetch('http://localhost/')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With