On invoking the below function, the console message “Token rule update with new token” is logged, but when actually invoking the web-socket connection request, the request header is not updated.
Has anyone faced this issue?
I got few articles that this is chrome bug, is this fixed yet?
function updateTokenRule(token) {
const rule = {
id: RULE_ID_TOKEN,
priority: 1,
action: {
type: "modifyHeaders",
requestHeaders: [
{
header: "token-header",
operation: "set",
value: token,
},
],
},
condition: {
urlFilter: "wss://localhost:19457/",
// resourceTypes: ["websocket"],
},
};
chrome.declarativeNetRequest.updateDynamicRules(
{
removeRuleIds: [RULE_ID_TOKEN],
addRules: [rule],
},
() => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
} else {
console.log("Token rule updated with new token:", token);
}
}
);
}