niklasvh / html2canvas-proxy-nodejs

Express middleware proxy for html2canvas
https://html2canvas.hertzen.com/
119 stars 38 forks source link

Proxy setup incorrect? #1

Closed kevinchiu closed 8 years ago

kevinchiu commented 8 years ago

I set up a node/express project on heroku and made modifications to app.js following the instructions on the front page like so:

var proxy = require('html2canvas-proxy');
var express = require('express');

var app = express();
var port = (process.env.PORT || 3000);

app.use("/", proxy());
app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
  next();
});
app.listen(port);

I put the url into the 'proxy' property of html2canvas like so. (The actual domain has been changed to protect the proxy.)

proxy: 'https://proxy.domain.com',  
height: $('.react-grid-layout').height(),
width: $('.react-grid-layout').width(),
background: '#FFFFFF',
allowTaint: false

I continue to get this error when trying to export canvases that refer to external image urls:

Image from origin 'https://proxy.domain.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://trays-staging.herokuapp.com' is therefore not allowed access. The response had HTTP status code 503.

https://proxy.domain.com/?url=http%3A%2F%2F7-themes.com%2Fdata_images%2Fuserpics%2Fu_18.gif Failed to load resource: the server responded with a status of 503 (Service Unavailable)

Image from origin 'https://proxy.domain.com' has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://trays-staging.herokuapp.com' is therefore not allowed access. The response had HTTP status code 503.

https://proxy.domain.com/?url=http%3A%2F%2F7-themes.com%2Fdata_images%2Fout%2F41%2F6909460-colorful-spirals.jpg Failed to load resource: the server responded with a status of 503 (Service Unavailable)
kevinchiu commented 8 years ago

Nevermind. It works!