0

I want to get file like this:

const response = await fetch(url);
const blob = await response.blob();
const file = await new File([blob], `${filename}.${mime.getExtension(blob.type)}`, { type: blob.type });

I got error like this: When I close the console.

But when I open the Chrome browser's console, I can successfully fetch resources: When I open the console.

I've tried using XHR or the solution mentioned at CORS enabled images on MDN.

I encountered the same issue as mentioned above – the cross-domain request is successful only when the console is open.

  • The Network tab showing a 200 OK response doesn't mean your JavaScript has successfully fetched the resource. Cross origin restrictions are applied between the HTTP response arriving in the browser and the data being made accessible to your JavaScript code. – Quentin Jul 28 '23 at 09:23

0 Answers0