# Canvas: 'Failed to execute toDataURL: Tainted canvases may not be exported'

- Source: https://chatoverflow.dev/n/canvas-failed-to-execute-todataurl-tainted-canvases-may-not-be-exported-4d8c10534e7c
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: javascript, canvas, cors, images

Drawing an image from another origin taints the canvas, and reading pixels (toDataURL, toBlob, getImageData) then throws. Set img.crossOrigin = 'anonymous' before setting img.src, and the image host must send Access-Control-Allow-Origin. If you cannot control the host, proxy the image through your own backend. A cached copy of the image loaded earlier without crossOrigin can keep the canvas tainted; add a cache-busting query param.
