title: Correct proxy script for html2canvas
body: <p>I'm trying to get <strong>html2render</strong> ( <a href="http://html2canvas.hertzen.com/" rel="nofollow">http://html2canvas.hertzen.com/</a> ) to work on my website. It works for the basic stuff - but none of the images show (as they are on a cdn.domain.com subdomain).</p>
  
  <p>I've been reading up, and it seems that it doesn't like other domains out of the box. I found a couple of PHP proxy scripts:</p>
  
  <ul>
  <li><a href="https://github.com/brcontainer/html2canvas-php-proxy" rel="nofollow">https://github.com/brcontainer/html2canvas-php-proxy</a></li>
  <li><a href="https://github.com/adjdred/html2canvas-proxy-php" rel="nofollow">https://github.com/adjdred/html2canvas-proxy-php</a></li>
  </ul>
  
  <p>I tried to get those going, but we don't have <em>curl</em> enabled on this server. So, I'm resorting to writing something in Perl. </p>
  
  <p>Here is what I've got so far:</p>
  
  <pre><code>use MIME::Base64;
  use File::Slurp;
  
  handle();
  
  sub handle {
  
      print ('Access-Control-Max-Age:' . 5 * 60 * 1000);
      print ("Access-Control-Allow-Origin: *");
      print ('Access-Control-Request-Method: *');
      print ('Access-Control-Allow-Methods: OPTIONS, GET');
      print ('Access-Control-Allow-Headers *');
      print ("Content-Type: application/javascript");
  
      #print $IN-&gt;header;
  
      my $url = $IN-&gt;param('url');
  
      $url =~ s|https://cdn.xxx.net|/srv/www/xxx.net/www|g;
  
      if (-e $url) {
  
          my $file = read_file($url);
  
          use JSON;
  
          my $mime_type;
          if ($url =~ /\.jpe?g$/i) {
              $mime_type = "image/jpg"
          } elsif ($url =~ /\.png$/i) {
              $mime_type = "image/png"
          }
          print JSON::encode_json([{
              "pathinfo" =&gt; $url,
              "error" =&gt; undef,
              "data" =&gt; encode_base64($file),
              "mime_type" =&gt; $mime_type
          }]);
      } else {
          print "ACK!";
      }
  
  }
  </code></pre>
  
  <p>However, it still doesn't work :( There is little (none??) documentation on the proxy (apart from telling you that you need it in some cases!)</p>
  
  <p>Can anyone share what the outputted data should look like?  I tried to work it out based on the above example codes , but my PHP is a bit rusty (and I don't have a server with PHP and Curl enabled, that I can test it out on)</p>
  
  <p>Thanks!</p>