Honor proxy headers for Swagger server origin#66
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19bb8300a6
ℹ️ 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".
| final String proxyHost = firstHeaderValue(request.header("X-Forwarded-Host")); | ||
| if (hasText(proxyHost)) { | ||
| return proxyHost; |
There was a problem hiding this comment.
Include X-Forwarded-Port in proxy origins
When a reverse proxy exposes the service on a non-default port and sends it separately as X-Forwarded-Port (for example, X-Forwarded-Proto: https, X-Forwarded-Host: api.example, and X-Forwarded-Port: 8443), this builds https://api.example instead of https://api.example:8443. The generated OpenAPI server then directs Swagger UI requests to port 443 rather than the externally reachable service port.
Useful? React with 👍 / 👎.
Summary
Why
API Challenges production Swagger UI was generating http://apichallenges.eviltester.com as the request server while the UI is served over HTTPS, causing browser fetch/CORS failures. The production proxy supplies forwarded headers, so generated OpenAPI docs should use those before falling back to the direct Javalin request scheme/host.
Verification