[eric] auth: dev-only /api/dev/token so the split-port frontend can authenticate (404s when packaged)

This commit is contained in:
eric
2026-06-01 11:55:17 -07:00
parent 1a4a23f131
commit bcb88ebefb
4 changed files with 49 additions and 0 deletions
+12
View File
@@ -23,6 +23,18 @@ export async function refreshAuthToken(): Promise<string> {
} catch {
_authTokenCache = '';
}
return _authTokenCache;
}
// Dev (split-port, no Electron preload): the backend hands us the token over
// localhost. The route 404s in packaged builds, so this only fires under run.sh.
try {
const r = await fetch(`http://${host}:${port}/api/dev/token`);
if (r.ok) {
const data = await r.json();
_authTokenCache = typeof data?.token === 'string' ? data.token : '';
}
} catch {
_authTokenCache = '';
}
return _authTokenCache;
}