Custom app launcher, browser home page, and service monitor. cute.haus
homelab react typescript
0

Configure Feed

Select the types of activity you want to include in your feed.

return error for non-american locations

Aly Raffauf (Feb 1, 2026, 5:59 PM EST) e60860f4 0895325b

+45 -4
+16 -1
src/components/Weather.tsx
··· 48 48 const fetchWeather = (lat: number, lon: number) => { 49 49 fetch(`/api/weather?lat=${lat}&lon=${lon}`) 50 50 .then((response) => response.json()) 51 - .then((data) => setWeather(data)); 51 + .then((data) => { 52 + if (data.error) { 53 + setError(data.error); 54 + } else { 55 + setWeather(data); 56 + } 57 + }) 58 + .catch(() => setError("Failed to load weather")); 52 59 }; 53 60 54 61 navigator.geolocation.getCurrentPosition( ··· 61 68 }, 62 69 ); 63 70 }, []); 71 + 72 + if (error) { 73 + return ( 74 + <div className="p-4 rounded-xl bg-white/5 border border-rose-400/20 text-zinc-400"> 75 + {error} 76 + </div> 77 + ); 78 + } 64 79 65 80 if (!weather) { 66 81 return <div>Loading weather...</div>;
+29 -3
src/index.ts
··· 103 103 }, 104 104 ); 105 105 106 + if (!pointsResponse.ok) { 107 + return Response.json( 108 + { error: "Weather only available for US locations" }, 109 + { status: 400 }, 110 + ); 111 + } 112 + 106 113 const pointsData = await pointsResponse.json(); 107 - const forecastUrl = pointsData.properties.forecast; 108 - const forecastResponse = await fetch(forecastUrl); 109 - const forecastData = await forecastResponse.json(); 114 + const forecastUrl = pointsData.properties?.forecast; 110 115 116 + if (!forecastUrl) { 117 + return Response.json( 118 + { error: "Weather only available for US locations" }, 119 + { status: 400 }, 120 + ); 121 + } 122 + 123 + const forecastResponse = await fetch(forecastUrl, { 124 + headers: { 125 + "User-Agent": "(watsup, aly@aly.codes)", 126 + }, 127 + }); 128 + 129 + if (!forecastResponse.ok) { 130 + return Response.json( 131 + { error: "Weather forecast unavailable" }, 132 + { status: 502 }, 133 + ); 134 + } 135 + 136 + const forecastData = await forecastResponse.json(); 111 137 const location = pointsData.properties.relativeLocation.properties; 112 138 113 139 return Response.json({