embiem / react-canvas-draw

React Component for drawing in canvas
https://embiem.github.io/react-canvas-draw/
MIT License
902 stars 315 forks source link

Tainted canvas #70

Closed Drarig29 closed 4 years ago

Drarig29 commented 4 years ago

I tried the solution given here, but I have this error:

SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.

I found a solution, you'd only have one line just after this one: https://github.com/embiem/react-canvas-draw/blob/de4ec18601f769efa8b11b9e6ac5d86b23beb117/src/index.js#L168

You'd need to add:

this.image.origin =  "anonymous";
embiem commented 4 years ago

Thanks! I just pushed the fix using the crossOrigin API.