web extension fetch problem with firefox

Hi all, i just finished a tiny chrome extension, and wanted to post it for firefox too. the extension has only a popup page, and performs a simple fetch() request on a youtube account name (I.E. https://www.youtube.com/@anyAccountName) on firefox, i got a CORS problem. usually, i can solve the problem by adding headers. but i can't solve this one... The fun part, is that a fetch request on https://www.youtube.com works fine here is the manifest
{
"manifest_version": 3,
"author" : "me",
"name": "YT",
"description": "super description",
"version": "1.0",
"icons" : {
"48" : "img/icon-48.png",
"64" : "img/icon-64.png",
"128" : "img/icon-128.png"
},
"host_permissions":[
"https://*.youtube.com/*"
],
"action": {
"default_icon": "img/icon-48.png",
"default_popup": "popup.html"
}
}
{
"manifest_version": 3,
"author" : "me",
"name": "YT",
"description": "super description",
"version": "1.0",
"icons" : {
"48" : "img/icon-48.png",
"64" : "img/icon-64.png",
"128" : "img/icon-128.png"
},
"host_permissions":[
"https://*.youtube.com/*"
],
"action": {
"default_icon": "img/icon-48.png",
"default_popup": "popup.html"
}
}
and here is the popup.js
/* works fine */
fetch('https://www.youtube.com/');

/* fails (i tried multiple options) */
fetch(`https://www.youtube.com/@anyAccoundName`,{
mode: 'no-cors',
redirect: 'follow',
credentials: 'include',
referrerPolicy: 'no-referrer',
headers:new Headers({
'User-Agent': navigator.userAgent,
'Referer': 'https://www.youtube.com/'
})
});
/* works fine */
fetch('https://www.youtube.com/');

/* fails (i tried multiple options) */
fetch(`https://www.youtube.com/@anyAccoundName`,{
mode: 'no-cors',
redirect: 'follow',
credentials: 'include',
referrerPolicy: 'no-referrer',
headers:new Headers({
'User-Agent': navigator.userAgent,
'Referer': 'https://www.youtube.com/'
})
});
any help would be appreciated :/
4 Replies
clevermissfox
clevermissfox2mo ago
Check Firefox setting content.cors.disable preference in about:config
Doksuri
DoksuriOP2mo ago
content.cors.disable = false if a user installs the exetension, i can't ask him to change his config... but my real interrogation is why does it work on youtube.com, but not on youtube.com/... ?
clevermissfox
clevermissfox2mo ago
Oh I thought this was for your own use. Not sure since you have .com/* could try to use regex in the js file and see if that works any better
Doksuri
DoksuriOP2mo ago
what ? i think you didn't understand the problem my web extension works perfectly on chrome but not on firefox when debugging, i found that my fetch request on https://www.youtube.com/@example failed and had CORS problem when testing a fetch request on https://www.youtube.com/ the request works fine i can't figure that one out :/
Want results from more Discord servers?
Add your server