mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-01 22:29:44 +08:00
88585a2024
## Description Self-hosted GitHub OAuth login fails at token exchange because the outbound request to `https://github.com/login/oauth/access_token` has no `User-Agent` header. GitHub then returns 403 ("Request forbidden by administrative rules"), which is surfaced as `INVALID_OAUTH_CALLBACK_CODE`. OAuth `safeFetch` only forwarded `authorization`, `content-type`, and `accept`, so even a User-Agent on the request would be stripped. This change: - allows `user-agent` in OAuth `fetchOptions()` - always sends `User-Agent: AFFiNE-Server` from `fetchJson()` (covers token exchange and `api.github.com` user/email fetches) Fixes #15521 ## Checklist - [x] The PR targets the `canary` branch and its title follows Conventional Commits - [x] Tests are added or updated where it makes sense <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved OAuth request compatibility by including a standard `User-Agent` header. * Ensured the header is permitted consistently during OAuth token exchanges. * **Tests** * Added coverage to verify case-insensitive handling of the `User-Agent` header in GitHub OAuth requests. <!-- end of auto-generated comment: release notes by coderabbit.ai --> ---------