diff --git a/api/src/routes/fcc-lookup.ts b/api/src/routes/fcc-lookup.ts index f9da0c0..b429aed 100644 --- a/api/src/routes/fcc-lookup.ts +++ b/api/src/routes/fcc-lookup.ts @@ -1280,12 +1280,18 @@ router.get("/api/v1/fcc/cores-search", async (req, res) => { }); if (!resp.ok) { - res.status(502).json({ error: `FCC search returned ${resp.status}` }); + res.status(502).json({ error: `The FCC search system is temporarily unavailable (HTTP ${resp.status}). Try searching by FRN instead, or try again in a few minutes.` }); return; } const html = await resp.text(); + // FCC sometimes returns 200 but with a maintenance/error page + if (html.includes("Service Unavailable") || (html.includes("503") && !html.includes("499results"))) { + res.status(502).json({ error: "The FCC search system is temporarily unavailable. Try searching by FRN instead, or try again in a few minutes." }); + return; + } + // Parse the results table rows: 834314 ... Carrier One Inc.DBA const rowRegex = /(\d+)<\/th>\s*\n?\s*([^<]+)<\/a><\/td>([^<]*)<\/td><\/tr>/gi; const results: { filer_id: string; legal_name: string; dba: string }[] = [];