webfactorymk / ng2-canvas-whiteboard

Canvas whiteboard
MIT License
99 stars 50 forks source link

Fix for CORS images on canvas #67

Open Elvander opened 4 years ago

Elvander commented 4 years ago

Loading an image as background from another domain is possible, but when saving the image an error is thrown (Firefox).

ERROR DOMException: The operation is insecure.

This happens when calling the canvasToDataUrl on a canvas.

More information: https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image

Peshou commented 4 years ago

Hi, I am not sure about merging the PR, please check this issue and the comments about why Cors taints the canvas as a security feature and how to overcome it

https://github.com/webfactorymk/ng2-canvas-whiteboard/issues/8

Elvander commented 4 years ago

The problem is that sometimes that there are no efficient ways to overcome this. For example a CDN server , even on the same top domain. Loading it through a proxy to map it to a base64 would add some extra delay/bandwidth.

How about I make this a property to allow 'insecure' image loading? The default would be not to allow this, except if we enable the feature through a property?