Skip to content

Honor proxy headers for Swagger server origin#66

Merged
eviltester merged 1 commit into
masterfrom
codex/proxy-aware-swagger-origin
Jul 17, 2026
Merged

Honor proxy headers for Swagger server origin#66
eviltester merged 1 commit into
masterfrom
codex/proxy-aware-swagger-origin

Conversation

@eviltester

Copy link
Copy Markdown
Owner

Summary

  • prefer Forwarded / X-Forwarded-Proto / X-Forwarded-Host when generating OpenAPI server origin
  • keep localhost as the preferred server when running locally without proxy headers
  • add tests for local and proxy/TLS production origin handling

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

  • mvn -pl thingifier '-Dtest=uk.co.compendiumdev.thingifier.adapter.httpserver.HttpRequestOriginTest' test
  • mvn -pl thingifier -DskipTests checkstyle:check@project-fqn-check
  • mvn -pl challenger '-Dtest=uk.co.compendiumdev.uirouting.UiPagesAreReachableTest#canFetchDefaultOpenApiJsonForSwaggerUi' test (from apichallenges, using locally installed Thingifier snapshot)

Copilot AI review requested due to automatic review settings July 17, 2026 08:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@eviltester
eviltester merged commit 389312e into master Jul 17, 2026
3 checks passed
@eviltester
eviltester deleted the codex/proxy-aware-swagger-origin branch July 17, 2026 08:13

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +31 to +33
final String proxyHost = firstHeaderValue(request.header("X-Forwarded-Host"));
if (hasText(proxyHost)) {
return proxyHost;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants