← Back to context

Comment by dlazaro

3 days ago

There is no visible plumbing because it kinda is magic! Astro provides adapters for different server runtimes (e.g., Vercel, Cloudflare, Netlify), and it's basically just plug and play. The Cloudflare adapter exposes a bunch of bindings [1] through `Astro.locals.runtime`, which can be accessed during each request. The `cf` binding contains incoming request properties [2], including latitude and longitude.

These bindings (or at least some of them) are also mocked when developing locally, in a non-Cloudflare-Workers environment.

[1] https://developers.cloudflare.com/workers/wrangler/api/#supp...

[2] https://developers.cloudflare.com/workers/runtime-apis/reque...

Any ideas on how to do this without the Cloud flare magic, so entirely in the client? Just based on time will suffice, with latitude approximated to somewhere such as London?