Reputation: 101
I try to fetch data from my background script like recommended here but it always got blocked. did i miss something?
Background.js:
chrome.storage.sync.get(['sigurl'], function(result) {
console.log(result.sigurl);
fetch(result.sigurl)
.then((response) => {
return response.text();
})
.then((html) => {
console.log(html);
chrome.storage.sync.set({'sig': html}, function() {});
})
.catch(function(err) {
console.log('Failed to fetch page: ', err);
});
});
Console:
Access to fetch at 'http://example.com/test.html' from origin 'chrome-extension://pbflkjmmkpgddamdcihlbggdccjmjmbk' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
use no-cors mode didn’t work either.
Upvotes: 0
Views: 1670
Reputation: 101
The solution for my problem is adding
"permissions": [
"https://*/"
]
to my manifest.json
Thank you to wOxxOm for pointing me in the right direction.
Upvotes: 3