Mirror cdn request to worker

I have a r2 bucket with a custom domain so there's cdn in front. Is it possible mirror cdn requests to a worker? Alternatively I can override certain paths using workers routes but I haven't found a method to pass request from worker to r2. Is there such a thing?
2 Replies
Chaika
Chaika9mo ago
If you have a worker over a route with an origin behind it, you can just pass the request through, ex: await fetch(request) If you want your worker to handle fetching R2 directly, there's R2 Bindings, and this very nice library which takes care of all the hard-work of catching/range headers/etc which you can just pass requests to: https://github.com/kotx/render
GitHub
GitHub - kotx/render: Cloudflare Worker to proxy and cache requests...
Cloudflare Worker to proxy and cache requests to R2 - kotx/render
Sakari E
Sakari EOP9mo ago
Perfect, thank you!
Want results from more Discord servers?
Add your server