7

I'm using html2canvas plugin to generate snapshot of web pages. The problem is that everything runs ok in the localhost, however when deployed on the remote server I get the following error : Unable to get image data from canvas because the canvas has been tainted by cross-origin data.

I've found a plugin that is supposed to work : https://github.com/niklasvh/html2canvas-proxy

The problem is that I don't know how to use it !

Similar question is asked here but remains without answer : https://github.com/niklasvh/html2canvas/issues/61

amine
  • 181
  • 1
  • 2
  • 9

1 Answers1

4

I've solved this issue, the proxy code needs to be added to the server side scripts. Then I needed to change the order of if statements to make calling the proxy the first choice since it will be the case for all the images we are dealing with in our project. Thanks Niklas. More details are here : https://github.com/niklasvh/html2canvas-proxy/issues/2#

amine
  • 181
  • 1
  • 2
  • 9
  • 1
    This proxy can be used for taking screenshots of live streaming video? – Jayna Tanawala May 19 '21 at 10:15
  • 4
    Can you provide some example code that how you have managed if statement to call proxy first? – Jayna Tanawala May 19 '21 at 10:42
  • @amine Struggling with the same. Could you please help me out here? We essentially need to install h2can-proxy and pass the url as a parameter to get a base64 image right? It works with an image source but fails to work for any other pages. – Vayun Jan 20 '23 at 07:45