From 56e0386c46a8ca5bfd4b210a30163665880f9fe8 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Sun, 26 Apr 2026 12:02:33 -0400 Subject: [PATCH] get lat/lon for weather from cloudflare headers --- src/components/Weather.tsx | 2 +- src/index.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Weather.tsx b/src/components/Weather.tsx index daa33a3..175bcb0 100644 --- a/src/components/Weather.tsx +++ b/src/components/Weather.tsx @@ -46,7 +46,7 @@ export function Weather() { useEffect(() => { const fetchWeather = (lat: number, lon: number) => { - fetch(`/api/weather?lat=${lat}&lon=${lon}`) + fetch(`/api/weather`) .then((response) => response.json()) .then((data) => { if (data.error) { diff --git a/src/index.ts b/src/index.ts index cc94ee4..03e9297 100644 --- a/src/index.ts +++ b/src/index.ts @@ -90,8 +90,8 @@ const server = serve({ "/api/weather": { async GET(req) { const url = new URL(req.url); - const lat = url.searchParams.get("lat"); - const lon = url.searchParams.get("lon"); + const lat = req.headers.get("cf-iplatitude") ?? "33.749"; + const lon = req.headers.get("cf-iplongitude") ?? "-84.388"; try { const pointsResponse = await fetch( -- 2.51.2