How to get origin URL on Deno Deploy?
What's the right way to get the origin URL
https://user-repo.deno.dev
in a Deno Deploy worker?
I could hardcode it, but would need to keep it in sync with a custom domain, etc. It seems globalThis.location
isn't set on Deploy!?1 Reply
not sure if it's the "right way" but use deno.env and then set the origin/domain as env variable on the deploy? It's an extra step but at least it's a bit better than hard coded
Though you'll have to be mindful of server / frontend code and get the env variable via the server and provide it to your frontend somehow if your frontend needs it
for frontend code, globalThis should be the same as window, but window.location shouldn't have anything to do with deno deploy if ran in frontend code. It asks the current browser what it's location is.