From abf04aabbd530106d551314c455b40b82d56d1f3 Mon Sep 17 00:00:00 2001 From: Capucine Gest Date: Thu, 28 May 2026 20:29:02 +0200 Subject: [PATCH] Add User-Agent header to Stooq fetch to avoid server-side blocking Co-Authored-By: Claude Sonnet 4.6 --- app/api/drivers/route.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/api/drivers/route.ts b/app/api/drivers/route.ts index 4c2989f..00dfe59 100644 --- a/app/api/drivers/route.ts +++ b/app/api/drivers/route.ts @@ -43,7 +43,10 @@ async function stooqMetal(symbol: string): Promise { const empty: FredResult = { value: null, delta: null, deltaPct: null }; try { const url = `https://stooq.com/q/l/?s=${symbol}&f=sd2t2ohlcv&h&e=csv`; - const res = await fetch(url, { next: { revalidate: 300 } }); // cache 5 min + const res = await fetch(url, { + next: { revalidate: 300 }, // cache 5 min + headers: { "User-Agent": "Mozilla/5.0 (compatible; ForexDashboard/1.0)" }, + }); if (!res.ok) return empty; const text = await res.text(); const lines = text.trim().split("\n");