Skip to content

fix: replace deprecated proxy.Director with Rewrite in reverse proxy#15

Merged
ogulcanaydogan merged 1 commit into
mainfrom
fix/proxy-director-deprecation
May 13, 2026
Merged

fix: replace deprecated proxy.Director with Rewrite in reverse proxy#15
ogulcanaydogan merged 1 commit into
mainfrom
fix/proxy-director-deprecation

Conversation

@ogulcanaydogan
Copy link
Copy Markdown
Owner

Summary

  • Replaces httputil.ReverseProxy.Director with ReverseProxy.Rewrite in pkg/proxy/server.go
  • Director is deprecated since Go 1.26 (staticcheck SA1019); golangci-lint flags it as an error, blocking the go-weekly-rollup Dependabot PR
  • Rewrite achieves identical Host-preservation behaviour (r.SetURL(target) + r.Out.Host = target.Host) and has been available since Go 1.20
  • Updates CHANGELOG.md Unreleased

This unblocks Dependabot PR #13 (go-weekly-rollup) which exposed the deprecation via a Go toolchain bump.

Test plan

  • go build ./pkg/proxy/... passes
  • go test ./pkg/proxy/... passes (all tests green)
  • CI Lint (staticcheck SA1019 no longer triggered)
  • CI Test (Go) passes end to end

httputil.ReverseProxy.Director is deprecated since Go 1.26 (staticcheck
SA1019). ReverseProxy.Rewrite achieves the same Host-preservation
behaviour and has been available since Go 1.20. This unblocks the
go-weekly-rollup Dependabot PR that bumped dependencies requiring the
newer Go toolchain where staticcheck flags the deprecated usage.
Copy link
Copy Markdown

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

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: de3965037c

ℹ️ 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 thread pkg/proxy/server.go
Comment on lines +39 to +41
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(target)
r.Out.Host = target.Host
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore forwarded headers in Rewrite proxy path

Switching from Director to Rewrite changes header behavior: with Rewrite, Forwarded/X-Forwarded-* headers are stripped before your callback and are not re-added unless ProxyRequest.SetXForwarded() is called. The previous Director-based proxy automatically populated X-Forwarded-For, so this commit drops client forwarding metadata for all proxied requests. Upstreams that rely on those headers for IP-aware auth/rate-limiting/auditing will now see missing or incorrect client identity.

Useful? React with 👍 / 👎.

@ogulcanaydogan ogulcanaydogan merged commit 4125218 into main May 13, 2026
12 checks passed
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.

1 participant