Can't access worker "route" from inside SvelteKit worker function

I have a worker that uploads images to R2, and I call it via a fetch via an API route in my SvelteKit application. I have a custom "route" assigned to it, that is in the same zone as the SvelteKit application (hosted on Cloudflare). It only works when I fetch the original URL .workers.dev, and not the custom one I have set up which is essentially site.com/image-upload/* even though if I go tot he URL via the browser, it works fine. is there a solution i ammissing here?
2 Replies
kian
kian12mo ago
Same-zone subrequests fall through to the origin, they can't hit another Worker. Worker-to-Worker communication should use Service Bindings: https://developers.cloudflare.com/workers/configuration/bindings/about-service-bindings/
Cory
CoryOP12mo ago
ah I see - do you have any example projects with this being used with SvelteKit?
Want results from more Discord servers?
Add your server