我正在使用https://cdnjs.com/libraries/dom-to-image截取图表,然后将其发送到我的后端服务器。整个过程在本地运行良好,但在部署到 AWS ec2 实例时出现错误
Uncaught (in promise) DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
我提出这个问题的代码的具体行是
domtoimage.toBlob(chartDom)
.then(function (blob) { //This causes the error
loader.style.display = 'flex'
let formData = new FormData();
阅读一轮显示了一个像设置这样的解决方案,crossOrigin="anonymous"
但我不确定在这种情况下我应该在哪里设置它。