internal/log: Implement logging of HOST when using subrequest auth (#1027)

* internal/log: Implement logging of HOST when using subrequest auth

The host header wouldn't be set on subrequest auth, so we need to look for X-Forwarded-Host header when logging requests.

* chore: add changelog entry

---------

Signed-off-by: Xe Iaso <xe.iaso@techaro.lol>
Co-authored-by: Xe Iaso <xe.iaso@techaro.lol>
This commit is contained in:
Skyler Mäntysaari 2025-08-29 22:04:33 +03:00 committed by GitHub
parent 99bd06b8c3
commit 01f55cf552
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 44 additions and 2 deletions

View file

@ -27,8 +27,13 @@ func InitSlog(level string) {
}
func GetRequestLogger(base *slog.Logger, r *http.Request) *slog.Logger {
host := r.Host
if host == "" {
host = r.Header.Get("X-Forwarded-Host")
}
return base.With(
"host", r.Host,
"host", host,
"method", r.Method,
"path", r.URL.Path,
"user_agent", r.UserAgent(),