R2 bound worker + service worker with image resizing does not work
Hello guys! I'm new in the cloudflare space but love learning the systems.
I have an R2 storage which I have to keep private. On top of that I have a worker that is bound to it and serves images stored in a bucket. I have a second worker that is "service" bound to the R2 bound worker that I intend to have to serve optimized versions of the images. See the service bound worker script in the comments.
I can succesfully fetch an image from the .dev endpoint, but the image does not get resized with the width and height parameters. What am I doing wrong?
3 Replies
Worker script:
And yes I have a pro plan and activated the image optimization functionality
Ok maybe I've figured out something. According to https://developers.cloudflare.com/images/image-resizing/troubleshooting/ it says "There is another Worker running on the same request. Resizing is “forgotten” as soon as one Worker calls another. Do not use Workers scoped to the entire domain /*."
Does that mean that any fetch via service binding workers will prompt the resizing to be "forgotten" or whatever it means? Can someone clarify? When i set the R2 bound worker to a public route and call it not using env.SERVER.fetch but instead only fetch it seems to work.
Troubleshooting | Image Resizing · Cloudflare Image Optimization docs
Does the response have a Cf-Resized header? If not, then resizing has not been attempted. Possible causes:
Curious if you got resolution on this? Looking to do something similar