diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c73bc8..8793029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Replace deprecated `httputil.ReverseProxy.Director` with `Rewrite` in `pkg/proxy/server.go`; `Director` is deprecated since Go 1.26 (SA1019); `Rewrite` achieves the same Host-preservation behaviour and has been available since Go 1.20. + ## [1.3.0] - 2026-03-08 ### Added diff --git a/pkg/proxy/server.go b/pkg/proxy/server.go index ae82057..d8b71a3 100644 --- a/pkg/proxy/server.go +++ b/pkg/proxy/server.go @@ -35,13 +35,11 @@ func StartServer(opts ServerOptions, d detector.Detector) error { Level: slog.LevelInfo, })) - proxy := httputil.NewSingleHostReverseProxy(target) - - // Preserve the original Host header - originalDirector := proxy.Director - proxy.Director = func(req *http.Request) { - originalDirector(req) - req.Host = target.Host + proxy := &httputil.ReverseProxy{ + Rewrite: func(r *httputil.ProxyRequest) { + r.SetURL(target) + r.Out.Host = target.Host + }, } action := ParseAction(opts.Action)