Cloudflare Workers: download YouTube, TikTok and Instagram videos
A Worker is a cheap, fast place to hold the CrawlFetch key and add your own rate limiting at the edge.
How it fits together
The Worker receives ?url=, calls the API with a secret binding, and returns the result. Store files in R2 if you need to keep them.
Cloudflare Workers example
export default {async fetch(req: Request, env: { CRAWLFETCH_KEY: string; VIDEOS?: R2Bucket }) {const url = new URL(req.url).searchParams.get("url");if (!url) return new Response("url is required", { status: 400 });const r = await fetch("https://api.crawlfetch.com/v1/resolve?" + new URLSearchParams({ url }), {headers: { Authorization: "Bearer " + env.CRAWLFETCH_KEY },});return new Response(r.body, { status: r.status, headers: { "content-type": "application/json" } });},};
Notes for Cloudflare Workers
- Set the key with
wrangler secret put CRAWLFETCH_KEY. - Stream
downloadUrlinto R2 withenv.VIDEOS.put(key, res.body)to archive files.
FAQ
Is there a CPU-time problem with large files?
Streaming a body to R2 is I/O, not CPU, so it fits Worker limits for typical short-form video.
Related
Last updated 2026-10-25