Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 921 Bytes

File metadata and controls

39 lines (26 loc) · 921 Bytes

Cloudflare Workers Puppeteer

Just playing around with the Workers Browser Rendering API

It'll accept an URL, uses the Browser API to capture a screenshot of the full page and saves it to R2.

install everything:

npm i

create R2 bucket:

npx wrangler r2 bucket create my-bucket

rename wrangler.example.toml to wrangler.toml and add the r2 binding to it:

r2_buckets  = [
  { binding = "puppeteer", bucket_name = "my-bucket"}
]

you may want to make the r2 bucket public so you can access the screenshot directly, the Worker will do an redirect. Put the public bucket url into wrangler.toml as the bucketUrl environment variable.

deploy everything:

npm run deploy

take a screenshot:

https://your-worker.cool.workers.dev/?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ