简体   繁体   中英

Using url2png to capture a page on my own site

I am using url2png add-on on cloudinary CDN to capture an image of pages on my site. The code below will work when I try to capture an image on another site like can.com for instance. However, it will not work when I point it my own site.

What could be causing this? How do I get around it?

works:

image = Cloudinary::Uploader.explicit("http://www.cnn.com?unique=#{Time.now}/url2png/viewport=2200x680|unique=true",
                                  :type => "url2png")

doesn't work

image = Cloudinary::Uploader.explicit("localhost:3000?unique=#{Time.now}/url2png/viewport=2200x680|unique=true",
                                      :type => "url2png")

If I hit my staging url from dev it will also work.

EDIT

I'm now realizing that I am having this same experience on my staging server. So when I try to capture a page on my staging server from my staging server I get a 500 (timeout) but if I run the same code from localhost to staging it works. It feel like an origin issue or something. I'm not sure.

UPDATE

So I set up a subdomain on my staging server in hopes that I could hit sub.domain.com from www.domain.com and it would work... still doesn't work.

Cloudinary integrates with the url2png.com api to achieve the screenshot functionality. URL2PNG requires the page to be reachable from the internet.

You can use a tool like https://ngrok.com/ to make your localhost reachable from the internet.

See also: Access localhost from the internet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM