logoalt Hacker News

dlazarolast Saturday at 8:03 PM2 repliesview on HN

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...


Replies

Theodoreslast Sunday at 4:35 PM

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?

cloudfudgelast Saturday at 8:13 PM

Great explanation; thanks.