fix: resolve hub endpoint from --base-url flag#106
fix: resolve hub endpoint from --base-url flag#106ptone merged 2 commits intoGoogleCloudPlatform:mainfrom
Conversation
… localhost resolveHubEndpoint() checked the SCION_SERVER_BASE_URL env var but ignored the --base-url command-line flag. When the hub is started with --base-url https://scion.example.com, the hub endpoint still resolved to http://localhost:8080, which was then passed to the broker and injected into containers as SCION_HUB_ENDPOINT. This caused containers to fail hub connectivity — they received https://scion.example.com:8080 (the base URL with the internal web port appended) instead of just https://scion.example.com. Fix: check webBaseURL (the --base-url flag) first, then SCION_SERVER_BASE_URL env, then fall back to the computed localhost URL.
cmd/server_foreground.go
Outdated
| if enableDebug { | ||
| log.Printf("Hub endpoint resolved from --base-url flag: %s", hubEndpoint) | ||
| } | ||
| } else if baseURL := os.Getenv("SCION_SERVER_BASE_URL"); baseURL != "" { |
There was a problem hiding this comment.
should use guard clauses here and eliminate inline if/else
PR #106 Review: fix: resolve hub endpoint from --base-url flagPR: #106 Executive SummaryThis is a low-risk, well-scoped bug fix that refactors Critical IssuesNone. Observations1. Subtle behavioral change in the
|
* fix: resolve hub endpoint from --base-url flag before falling back to localhost resolveHubEndpoint() checked the SCION_SERVER_BASE_URL env var but ignored the --base-url command-line flag. When the hub is started with --base-url https://scion.example.com, the hub endpoint still resolved to http://localhost:8080, which was then passed to the broker and injected into containers as SCION_HUB_ENDPOINT. This caused containers to fail hub connectivity — they received https://scion.example.com:8080 (the base URL with the internal web port appended) instead of just https://scion.example.com. Fix: check webBaseURL (the --base-url flag) first, then SCION_SERVER_BASE_URL env, then fall back to the computed localhost URL. * fix: use guard clauses in resolveHubEndpoint
Summary
Fixes #104 — Hub endpoint ignores
--base-urlflag, falls back tolocalhost:8080.resolveHubEndpoint()checkscfg.Hub.EndpointandSCION_SERVER_BASE_URLenv but ignores the--base-urlCLI flag. When neither config nor env is set, it falls back tohttp://localhost:<webPort>, causing containers to receive the wrong hub endpoint.Fix: Check
webBaseURL(the--base-urlflag) first, before the env var and localhost fallback. One line added.Test plan
go build/go vetclean--base-url https://example.com— verifySCION_HUB_ENDPOINTin containers matches--base-url— verify fallback to localhost still worksSCION_SERVER_BASE_URLenv — verify env var still works