anvilsign in

collin/strudel-claude

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.
7let pending = null;
8
9export 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}