I am trying to modify origin header in a websocket creation process in a chrome extension.
I have declarativeNetRequestWithHostAccess in permissions.
I am trying to use a rule of type modifyHeaders.
It perfectly modifies the headers for fetch() calls but not for websockets.
What am I missing?
Here is the rule ie src/rules/example.json:
[
{
"id": 2,
"priority": 1,
"action": {
"type": "modifyHeaders",
"requestHeaders": [
{
"header": "origin",
"operation": "set",
"value": "https://www.example.ai"
},
{
"header": "referer",
"operation": "set",
"value": "https://www.example.ai"
}
]
},
"condition": {
"urlFilter": "example",
"isUrlFilterCaseSensitive": false,
"resourceTypes": ["xmlhttprequest", "websocket"]
}
}
]
Here is manifest.json
...
...
"declarative_net_request": {
"rule_resources": [
{
"id": "ruleset_example",
"enabled": true,
"path": "src/rules/example.json"
}
]
},
As @wOxxOm mentioned,
moving
"wss://*/*"fromoptional_host_permissionstohost_permissionssolved it.I guess for
optional_host_permissionsI had to callchrome.permissions.request({ origins: ['wss://example.com'] })as well which I was not doing.