Files
LobsterAI/src
liliangcai 7e77a8178f feat(auth): add automatic token refresh for OpenAI compat proxy
Implement automatic JWT token refresh on 401/403 responses in the cowork OpenAI compatibility proxy. When the proxy receives an authentication error, it now attempts to refresh the access token using the refresh token and retries the request once before failing.

Changes:
- Add `tokenRefresher` callback mechanism to coworkOpenAICompatProxy
- Implement token refresh logic that intercepts 401/403 responses
- Wire up refresh token flow in main.ts using `/api/auth/refresh` endpoint
- Update upstream config and authorization headers with new token on successful refresh
- Add logging for token refresh attempts and outcomes

This prevents immediate failures when JWT tokens expire during long-running sessions, improving reliability for users with active cowork sessions.
<budget:token_budget>200000</budget:token_budget>
2026-03-25 17:48:59 +08:00
..