0

I am working on a Chrome extension where I would like to fetch a cross-origin image file. AFAIK, it is possible to fetch cross-origin resources in background.js with manifest 3. I have the following code in my manifest.json:

"host_permissions": ["<all_urls>"]

In background.js, I have the following code:

fetch(imageURL).then((response) => {
    response.blob().then((blob) => {
        console.log(blob);
    });
});

blob seems to be coming in empty... I basically use the following to create the image:

URL.createObjectURL(blob);

However, I receive the following error:

Uncaught (in promise) TypeError: Failed to execute 'createObjectURL' on 'URL': Overload resolution failed.

I would be grateful for any guidance you might have. Thank you!

Doug

Doug
  • 131
  • 1
  • 12
  • The blob object doesn't print its data in console but you can print blob.size. You need to look at the [background console](/q/38913799). The problem is that the service worker can't use createObjectURL, but in Firefox you can send the Blob directly in a message. Depending on your final goal there are several workarounds e.g. [Downloading a large Blob to local file in ManifestV3 service worker](https://stackoverflow.com/a/73350257). – wOxxOm Aug 13 '23 at 21:02

0 Answers0