| 1 | // Backend capabilities: whether the server holds an API key, and which models |
| 2 | // it will accept. Fetched once and shared — several bits of UI want it, and the |
| 3 | // answer doesn't change while the page is open. |
| 4 | // |
| 5 | // Resolves to null if the backend is down or predates the endpoint; every caller |
| 6 | // has to cope with not knowing rather than block on it. |
| 7 | let pending = null; |
| 8 | |
| 9 | export function getConfig() { |
| 10 | pending ??= fetch('/api/config', { headers: { 'ngrok-skip-browser-warning': 'true' } }) |
| 11 | .then((r) => (r.ok ? r.json() : null)) |
| 12 | .catch(() => null); |
| 13 | return pending; |
| 14 | } |