Closed iamhrayr closed 2 years ago
Hi @iamhrayr ,
Thanks for reporting. What is your application's domain? If it's different than your image's domain, you are probably running into cross origin issues. Please let me know what location.origin
returns from your dev console.
If it's cross origin, please check this section of our docs when loading an image from a different origin. Basically, you need to make sure the server hosting your image should return the correct CORS headers, and set the crossOrigin attribute of the image object.
const getImage = (imageUrl: string) => {
return new Promise((resolve, reject) => {
const img = new Image();
img.crossOrigin = 'Anonymous'; // <-- IMPORTANT if serving from a different origin
img.src = imageUrl;
img.onload = () => resolve(img);
img.onerror = reject;
});
};
Unfortunately, you will not see an error when you run into this kind of issue. The browser fails silently when running into CORS issues when loading an image to a canvas.
@charliesantos thanks for the quick response. Yeah, it was the problem. After configuring the CORS of the server everything works as expected
closing the issue since it is not related to this library.
Code to reproduce the issue:
Expected behavior: IT should show the correct background or throw some error in case any.
Actual behavior: Shows black screen
Software versions: