diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 989eb83..aa8c6dd 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -361,7 +361,9 @@ async fn fetch_historical_rates( .timeout(std::time::Duration::from_secs(15)) .build() .map_err(|e| e.to_string())?; - let url = format!("https://api.frankfurter.app/{}?from=USD", date); + // api.frankfurter.app 301-redirects here now, and the old domain is + // flaky over reqwest/rustls-tls — go straight to the stable host + let url = format!("https://api.frankfurter.dev/v1/{}?from=USD", date); let body: serde_json::Value = client .get(&url) .send() diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cf73e82..c3314d5 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -23,7 +23,7 @@ } ], "security": { - "csp": "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src ipc: http://ipc.localhost https://open.er-api.com https://api.coingecko.com https://query1.finance.yahoo.com https://query2.finance.yahoo.com https://api.frankfurter.app" + "csp": "default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:; connect-src ipc: http://ipc.localhost https://open.er-api.com https://api.coingecko.com https://query1.finance.yahoo.com https://query2.finance.yahoo.com https://api.frankfurter.dev" } }, "bundle": { diff --git a/src/main.ts b/src/main.ts index f75fb0c..71ec438 100644 --- a/src/main.ts +++ b/src/main.ts @@ -816,6 +816,9 @@ async function boot(): Promise { (text) => workspace.evaluateSheet(activeDoc().id, text), data.contents[data.activeId] ?? "", ); + // the editor above was seeded directly with initialText (not via switchDoc), + // so a reopened sheet with "on 2024-01-01" needs its own historical-rate fetch + void fetchNeededHistoricalRates(data.contents[data.activeId] ?? ""); applySettings(); // sets the language before bindSettingsUI renders dynamic labels bindSettingsUI(); diff --git a/src/storage.ts b/src/storage.ts index 228d3d7..b9caf3a 100644 --- a/src/storage.ts +++ b/src/storage.ts @@ -212,7 +212,7 @@ export async function fetchHistoricalRates(date: string): Promise>("fetch_historical_rates", { date }); } - const res = await fetch(`https://api.frankfurter.app/${date}?from=USD`); + const res = await fetch(`https://api.frankfurter.dev/v1/${date}?from=USD`); const json = await res.json(); if (!json?.rates) return null; const out: Record = { USD: 1 };