fix(server): Last.fm 콜백을 https로 — 승인 후 돌아오지 못하던 것 - #35
Merged
Conversation
`tailscale serve`가 HTTPS를 종단하고 앱에는 평문 HTTP로 넘기므로 req.Scheme이 http다. 그대로 콜백을 만들었더니 실측에서 이렇게 나갔다: cb=http://oracle.oryx-skink.ts.net/admin/lastfm/callback 그 호스트의 80번에는 아무도 없어서 승인 후 브라우저가 "서버에 연결할 수 없습니다"로 끝난다. 설령 붙었더라도 state 논스 쿠키가 Secure라 평문으로는 실리지 않아 어차피 실패한다. X-Forwarded-Proto를 먼저 믿고, 없으면 루프백이 아닌 이상 https로 본다 — 관리자 쿠키가 이미 Secure라 이 화면 전체가 애초에 HTTPS를 전제로 한다. 로컬 개발(127.0.0.1)만 http로 남는다. 로컬 스모크는 127.0.0.1이라 이 버그가 드러나지 않았다. 테스트로 고정한다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #34로 넣은 Last.fm 계정 연결이 실제로 눌러 보니 승인 후 돌아오지 못했다(브라우저가 "oracle.oryx-skink.ts.net 서버에 연결할 수 없습니다").
원인
tailscale serve가 HTTPS를 종단하고 앱에는 평문 HTTP로 넘기므로req.Scheme이http다. 그대로 콜백을 만들었더니 운영에서 이렇게 나갔다:그 호스트의 80번 포트에는 아무도 없다(tailscale serve는 443만 연다). 설령 붙었더라도 state 논스 쿠키가
Secure라 평문 요청에는 실리지 않아 어차피 실패한다.로컬 스모크 테스트가 이걸 놓쳤다 —
127.0.0.1이라http가 정답이었고, 그래서 잘못된 값이 정상으로 보였다.고침
X-Forwarded-Proto를 먼저 믿고, 없으면 루프백이 아닌 이상 https로 본다. 관리자 쿠키가 이미Secure라 이 화면 전체가 애초에 HTTPS를 전제로 하므로 일관된 규칙이다. 로컬 개발(127.0.0.1·localhost)만http로 남는다.프록시가 여럿이면
X-Forwarded-Proto가"https, http"처럼 이어 붙으므로 맨 앞을 쓴다.검증
/admin/lastfm/connect의Location에서cb=https%3A%2F%2F…를 확인하고, 실제로 승인까지 돌려 볼 것.🤖 Generated with Claude Code