fix(rates): reduce cache TTL, expose fallback header and show stale data warning

This commit is contained in:
2026-03-09 18:17:01 +01:00
parent 1f86a5ead4
commit 10493826bf
4 changed files with 31 additions and 6 deletions

View File

@@ -28,9 +28,11 @@ export function useMarketRates() {
const payload = await response.json();
const parsed = parseRatesResponse(payload);
const isFallback = response.headers.get("X-Cache-Fallback") === "stale-on-error";
const fallbackError = response.headers.get("X-Cache-Fallback-Error");
setData(parsed);
setError(null);
setError(isFallback ? (fallbackError ?? "Upstream provider error") : null);
} catch (err) {
const message = err instanceof Error ? err.message : "Unknown error";
setError(message);