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(