From e754911e0b0e40d93cb3142416dca0d7502c7276 Mon Sep 17 00:00:00 2001 From: Satyam-Rastogi Date: Tue, 19 May 2026 02:39:19 +0530 Subject: [PATCH] fix(storm-intel): graceful hail proxy error + suppress inflated homes total MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hail Recon fetch now checks Content-Type before parsing JSON — when running under pnpm dev (Vite only), the proxy JS file is served as-is; the check catches the non-JSON response and flags it as proxy_unavailable, surfacing "Not available in dev mode" instead of the raw parse-error string. Est. Homes header now shows "—" when no events are event-pinned. The previous totalHomes sum across all 37 NWS warning polygons (each 100–500 sq mi) produced a nonsensical 19.7M figure. The number is only meaningful per-event or when the user explicitly pins events to compare. --- src/pages/StormIntelPage.jsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pages/StormIntelPage.jsx b/src/pages/StormIntelPage.jsx index c255da7..83b01f7 100644 --- a/src/pages/StormIntelPage.jsx +++ b/src/pages/StormIntelPage.jsx @@ -1352,7 +1352,13 @@ const StormIntelPage = () => { const [lat, lng] = pin; setPinHailData(prev => ({ ...prev, [idx]: { loading: true, data: null, error: null } })); fetch(`/api/hail-proxy?endpoint=ImpactDatesForLatLong&Lat=${lat}&Long=${lng}&Months=60`) - .then(r => r.json()) + .then(async r => { + const ct = r.headers.get('content-type') || ''; + if (!ct.includes('json')) throw new Error('proxy_unavailable'); + const body = await r.json(); + if (!r.ok) throw new Error(body?.error || `HTTP ${r.status}`); + return body; + }) .then(data => setPinHailData(prev => ({ ...prev, [idx]: { loading: false, data, error: null } }))) .catch(err => setPinHailData(prev => ({ ...prev, [idx]: { loading: false, data: null, error: err.message } }))); }); @@ -1469,11 +1475,11 @@ const StormIntelPage = () => {

Storms

-
-

+

+

{pinnedHomes !== null ? (pinnedHomes >= 1000 ? `${(pinnedHomes / 1000).toFixed(1)}k` : pinnedHomes.toLocaleString()) - : (totalHomes >= 1000 ? `${(totalHomes / 1000).toFixed(1)}k` : totalHomes.toLocaleString()) + : '—' }

@@ -1829,7 +1835,9 @@ const StormIntelPage = () => { ); } else if (entry.error) { - line = Error: {entry.error}; + line = entry.error === 'proxy_unavailable' + ? Not available in dev mode + : {entry.error}; } else { const parsed = parseHailReconData(entry.data); if (!parsed) {