Skip to content

Commit e037f0a

Browse files
sammacbethlidel
authored andcommitted
fix: Improve extraHeaders feature detection (#787)
On Firefox forks the runtime.isFirefox detection was failing because the browser name was not 'Firefox'. This lead to an error when registering webRequest listeners as the extraHeaders option is not needed, preventing the extension from loading. There is an extension API that can be used to detect support for this option: OnBeforeSendHeadersOptions. This fix updates the feature detection check to explicitly look for this API. We also check to for the presence of OnBeforeSendHeadersOptions as it does not exist on Edge.
1 parent d01b2d3 commit e037f0a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

add-on/src/lib/ipfs-companion.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ module.exports = async function init () {
9797

9898
function registerListeners () {
9999
const onBeforeSendInfoSpec = ['blocking', 'requestHeaders']
100-
if (!runtime.isFirefox) {
100+
if (browser.webRequest.OnBeforeSendHeadersOptions && 'EXTRA_HEADERS' in browser.webRequest.OnBeforeSendHeadersOptions) {
101101
// Chrome 72+ requires 'extraHeaders' for access to Referer header (used in cors whitelisting of webui)
102102
onBeforeSendInfoSpec.push('extraHeaders')
103103
}

0 commit comments

Comments
 (0)