async function addRefererToRequestHeader() {
const ruleId = 1;
const rules = [{
id: ruleId,
action: {
type: 'modifyHeaders',
requestHeaders: [
{
header: 'Referer',
operation: 'set',
value: 'this-is-a-referer-header',
},
],
},
condition: {
resourceTypes: ['sub_frame'],
urlFilter: '<all_urls>',
},
}];
try {
await browser.declarativeNetRequest.updateDynamicRules({
removeRuleIds: rules.map(r => r.id),
addRules: rules,
});
console.log('Rules added successfully.');
} catch (error) {
console.error('Error adding rules:', error);
}
}
I have included this call in app install handle event.
```
I have these permissions in my manifest:
```
"permissions": ["scripting", "activeTab", "contextMenus", "storage", "tabs", "declarativeNetRequestWithHostAccess",
"declarativeNetRequestFeedback"],
"host_permissions":[
"<all_urls>"
]
```
I am using chrome://net-export to check for the added header. I have tried finding the header value, 'this-is-a-referer-header', in the log file generated but I couldn't find the value. What am I missing? Is it even possible to add Referer header. If yes, how?
TIA
--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/be1a85f4-35d0-44ff-81c0-c01289a604fcn%40chromium.org.