Say hello to the edge
A tiny interactive tool that asks the nearest Cloudflare data centre who you are.
Building thingsThe site is static — except when it isn’t. Any file in the repo’s functions/ folder becomes an
API route running on Cloudflare, on the same domain as the pages. This button calls
/api/whoami, which answers from whichever data centre is closest to you.
- Data centre
- —
- Country
- —
- City
- —
- Round trip
- —
How it works
- Front-end: an Astro component with a small
<script>, embedded in this MDX file. - Back-end:
functions/api/whoami.ts, a ~20-line Pages Function that readsrequest.cf.
Any future tool follows the same pattern: a component in src/components/tools/, an item with
type: tool that embeds it, and — only if needed — a function in functions/api/.