2

I am trying to use the library html-to-image, I am using it to convert my HTML into a downloadable PNG file.

However I get a CORS error when I try to download my image HTML element, which is using a src attribute with a link. The error is shown below

Access to fetch at 'https://amazon.s3.com/23424324.jpg' from origin 'https://localhost:8080' 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.

I tried to put the attribute crossorigin="anonymous" on my Image but this didn't fix the error, and actually made the image not show on my local environment. Just was hoping someone possibly had the same issue when trying to download images using a client side HTML to image download library, let me know any other alternatives if this can't be fixed.

Thank you!

Kaiido
  • 123,334
  • 13
  • 219
  • 285
br97
  • 41
  • 8
  • If your bucket isn't set to accept cross-origin requests you won't be able to export its content. Also beware even when you'll set up your bucket, [S3 and Chrome are not friends](https://stackoverflow.com/questions/49503171/the-image-tag-with-crossorigin-anonymous-cant-load-success-from-s3/49503414#49503414), be sure to clear the cache of the latter and to always request the data as crossorigin="anonymous". – Kaiido Jul 20 '21 at 06:41

0 Answers0