I am trying to use htmlToImage method but is is showing error "Access to fetch at " / aws image url / " from origin 'http://localhost:4200' 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."
The image url which I am using in img
tag, is coming from aws s3 bucket. And on AWS s3 we have already configured CORS
- AllowedOrigins as "*".
- AllowedHeaders as "*".
Note:
- This is working fine in firefox browser but not working in chrome browser and Opera browser.
- When I am opening genrated base64 in browser tab, the image is not coming. only blank is coming.
My html code is :
<div id="editedimage">
<img class="img-style" src="<imgUrl>" alt="image">
<div>
And js code is :
var node = document.getElementById('editedimage');
htmlToImage.toPng(node)
.then((dataUrl) => {
console.log("url", dataUrl);
.catch((error) => {
console.error("error", error);
});
Team, Help me out.
Thanks in advance.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…