Search code examples
proxyhtml2canvas

How to take cross origin screenshots using html2canvas-proxy


Struggling to use the html2canvas-proxy for cross origin screenshots. As far as I understand, passing the url as a parameter(localhost:xxxx?url=https://...) returns the image screenshot data as a base 64 string (check blob). This works only if the url parameter is an image source. On using any other url and using the same as an image source, I just get the alt text.

For example the proxy works with https://placebear.com/200/300 but fails to work with https://google.com as the url parameter.

Any help would be much appreciated


Solution

  • The html2canvas-proxy is only intended for use in combination with the html2canvas library itself. It's a NodeJS server with CORS enabled so that html2canvas can send the cross-domain image URLs to and receive the corresponding base64 data URL for processing in the canvases.

    It doesn't work as a server that takes in a website URL and returns a screenshot of that website.