[DONE] Blocked by CORS policy

I’m trying to download images saved on tape from another platform via API and I’m receiving the following error:
Access to XMLHttpRequest at ‘image link’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Is there any way to solve this problem?

1 Like

Hi @joao.matheus,

thanks for sharing your issue.

CORS is a security feature employed by browsers - so we assume you are trying to directly download or display images from Tape via another web application inside a browser?

Technically, if you are building a custom web app you might want to proxy the images, by either uploading them to your own server directly and and then access that URL, or proxy the request via your own backend (server side requests do not run into CORS issues as they only apply in browser environments). :eyes:

Maybe other users can also share their experience, if they ran into this in the past, and which option they chose to solve it. :slight_smile:

Cheers
Tim

1 Like

Yea I use a worker to be a ‘CORS proxy’ so the worker gets the image and then streams it into the browser, part of it:

return new Response(imageResponse.body, {
  headers: {
    "Content-Type": imageResponse.headers.get("Content-Type") || "image/png",
    "Cache-Control": "public, max-age=604800",
  },
});
2 Likes