get the url of your app in a worker?
Is there a way to get the url of where your app is deployed inside a worker? In a service worker i can do self.location, but it doesnt exist in a worker
Bonus question: easy way to switch that url between localhost for dev
4 Replies
Like this?
Is there any way to get the url in the module scope? Or only at the moment a request comes in?
Only once a request comes in. This is because a Worker can be deployed on multiple Routes(Domains + Pathnames) simultaneously, and can theoretically be configured to answer for any domain, even ones you don't own, so other than reading your
wrangler.toml
/wrangler.json
at build time, there is no way to statically known where a Worker is deployed.Right, that makes sense
Thank you :)