const handleDownloadImage = async () => {
try {
const canvas = await html2canvas(cardRef.current);
console.log(cardRef.current);
const imageData = canvas.toDataURL("image/png");
setImageUrl(imageData);
} catch (error) {
console.error("Error capturing image:", error);
}
};
and Iam getting this error
#4 240ms Starting DOM parsing logger.ts:25:29
#4 273ms Starting renderer for element at 216,32 with size 400x450 logger.ts:25:29
#4 273ms Canvas renderer initialized (400x450) with scale 1 logger.ts:25:29
#4 278ms Error loading image https://userpic.codeforces.org/3332594/title/6e3ce0bb53e6ed79.jpg Home:13441:25
#4 295ms Finished rendering
How can handle this error
i think it’s because the image is online it’s working for my local images
Help me to fix this issue
2
Answers
few options to explore this error for better understanding
It looks like you would need to enable CORS in the h2ml2canvas options for this to work. It would need to be configured like:
instead of