Prefer configured HTTPS Swagger server for same host#67
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff90d5273b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (preferredUri.getPort() == -1 && configuredUri.getPort() == -1) { | ||
| return true; | ||
| } | ||
| return effectivePort(preferredUri) == effectivePort(configuredUri); |
There was a problem hiding this comment.
Treat explicit HTTP default ports as the same external host
When the reverse proxy supplies an origin such as http://apichallenges.eviltester.com:80 while the configured server is https://apichallenges.eviltester.com, this comparison returns false (80 != 443). preferServer then adds the HTTP current-request server instead of reusing the HTTPS server, recreating the browser-breaking mixed-content URL this change is intended to avoid. The no-port variant succeeds through the preceding special case, so default-port spelling alone changes the result.
Useful? React with 👍 / 👎.
Summary
Why
Production API Challenges is served over HTTPS, but its reverse proxy can leave the app seeing http://apichallenges.eviltester.com as the request origin. The API definition already declares https://apichallenges.eviltester.com, so Swagger should prefer that configured secure server and avoid generating a browser-breaking HTTP server URL.
Verification