mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
fix(auth): send an https redirect_uri so GitHub sign-in works
The OAuth app registers https://gh-stats.com/api/auth/github/callback, but the app was sending the http:// form. GitHub compares redirect_uri to the registered callback character for character, so it refused every attempt with "The redirect_uri is not associated with this application" and showed users a warning that the app might be redirecting them somewhere they were not expecting. Sign-in has been failing for everyone, and it gates themes, custom tags and achievements. _derived_redirect_uri built the URL from X-Forwarded-Proto, falling back to request.scheme. The cloudflared tunnel does not reliably forward that header, so the scheme resolved to http. The comment above it claimed the headers are set, which is what hid this. Anything that is not localhost or 127.0.0.1 is https. Local dev keeps working over plain http, pinned by a test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BwMoSbmK77Ph7XaV5YnAdS
This commit is contained in:
@@ -561,9 +561,16 @@ def auth_github_login():
|
||||
|
||||
|
||||
def _derived_redirect_uri() -> str:
|
||||
# Works behind cloudflared: the X-Forwarded-Proto/Host headers are set.
|
||||
# The tunnel does not reliably forward the original scheme, so
|
||||
# X-Forwarded-Proto can be absent and request.scheme is then http. GitHub
|
||||
# compares redirect_uri against the callback registered on the OAuth app
|
||||
# character for character, so an http:// value is rejected with "The
|
||||
# redirect_uri is not associated with this application" and sign-in becomes
|
||||
# impossible. Anything that is not a local dev host is served over https.
|
||||
proto = request.headers.get("X-Forwarded-Proto") or request.scheme
|
||||
host = request.headers.get("X-Forwarded-Host") or request.host
|
||||
if host.split(":")[0] not in ("localhost", "127.0.0.1"):
|
||||
proto = "https"
|
||||
return f"{proto}://{host}/api/auth/github/callback"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user