1. The Host check should have been using Hostname() instead as Host
includes port, so this never would have matched (oops)
2. Point #1 is moot because we actually don't need this check since the
frontend services will all ping the API backend we always want that
IP to be forwarded.
Changelog-fixed: Issue where IP was not being correctly forwarded to the
API server.
---
client.go | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/client.go b/client.go
index 84836b9..8855cdf 100644
--- a/client.go
+++ b/client.go
@@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
- "net/url"
"strings"
"time"
@@ -76,14 +75,9 @@ func Execute(ctx context.Context, op *gqlclient.Operation, result any) error {
token := grant.Encode(ctx)
trans.AddHeader("Authorization", fmt.Sprintf("Internal %s", token))
- ourl, err := url.Parse(origin)
- if err == nil {
- if ourl.Host == "127.0.0.1" || ourl.Host == "localhost" {
- ip := IPForContext(ctx)
- if ip != "" {
- trans.AddHeader("X-Real-IP", ip)
- }
- }
+ ip := IPForContext(ctx)
+ if ip != "" {
+ trans.AddHeader("X-Real-IP", ip)
}
httpClient = &http.Client{
@@ -92,7 +86,7 @@ func Execute(ctx context.Context, op *gqlclient.Operation, result any) error {
}
client = gqlclient.New(origin, httpClient)
- err = client.Execute(ctx, op, &result)
+ err := client.Execute(ctx, op, &result)
if err != nil {
if graphErrors, ok := err.(interface{ Unwrap() []error }); ok {
errs := graphErrors.Unwrap()
--
2.52.0
Applied.
To git@git.code.netlandish.com:~netlandish/links
20d5f0e..8e25a75 master -> master