mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-10-31 08:13:50 +00:00
OAuth authorization-server metadata lives at the origin root (RFC 8414), but getRequiredConfig() derived the discovery URL straight from JMAP_SERVER_URL. When that is the session URL (for example https://mail.example.com/jmap/session, a common setup so the client can skip the 307 redirect a preflighted CORS request cannot follow), discoverOAuth fetched https://mail.example.com/jmap/session/.well-known/oauth-authorization-server, got a 404, and token refresh failed with "OAuth token endpoint not found", so the session was dropped after one access-token lifetime. Strip a trailing session path (/jmap/session or /.well-known/jmap, plus any query or fragment) before discovery. A plain server root is unchanged, and only the session suffix is removed, so a real base path prefix is kept. Adds oauth-discovery-base.test.ts driving getRequiredConfig; the normalization cases fail without the fix.