Reputation: 39
We are using chrome webrequest API to intercept and modify headers on request.
I was working fine until Chrome 72, but it's not working anymore. But when I replacing the permission with "<all_urls>"
that's work.
Also, I tried with another domain, Google, like this example : https://developer.chrome.com/extensions/webRequest and that not working too.
Did you have any idea about why that not working anymore ?
We will use "<all_urls>"
for the moment but it's a huge permission that we do not really need.
manifest.json :
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*.merchantos.com/*"
]
background.js
chrome.webRequest.onHeadersReceived.addListener(
details => ({
responseHeaders: filter(details.responseHeaders),
}),
{ urls: ['*://*.merchantos.com/*'] },
['blocking', 'responseHeaders']
)
EDIT :
Problem solved. For Chrome 72 you now need to add the host of the request into your permission to be able to edit headers.
manifest.json :
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*.merchantos.com/*",
"*://*.mywebsite.coom/*/,
]
Upvotes: 2
Views: 7476
Reputation: 5109
With Chrome 72, you need to specify both the target URL that you want to intercept, and the website URL from which the request is made in the permissions.
For example: https://www.mywebsite.com/
makes a request to https://abc.merchantos.com
which you want to intercept. Thus:
You have to specify both those URLs in your manifest.json
:
{
...
"permissions": [
"webRequest",
"webRequestBlocking",
"*://*.mywebsite.com/*",
"*://*.merchantos.com/*"
],
...
}
Upvotes: 5