How to Interact with Service Workers from Pages Functions
Hi all,
I am building an Astro frontend Pages that will run its API code in a Functions directory, and I need to have it interact with another Cloudflare Worker that is another API that handles authentication.
This way I can decouple the Auth Worker as a microservice and have it interact with other Workers if needed. I made a simple diagram of this.
How would I go about binding the proper URL of this Auth worker in such a way that it is dynamically linked? I followed the advice here: https://docs.astro.build/en/guides/integrations-guide/cloudflare/#config
But this won't allow the binded Service Workers URL to get passed along into Astro's runtime; what is the recommended approach for this?
Thank you!
1 Reply
What do you mean by the URL won't be passed properly?
A service binding is the correct way. The Astro config is for local so it'll use a local host URL and port but for prod/preview you'll link the worker in the dashboard.