From 2ff7269a05d9ba0f12830d702c9faa3bf6767a6e Mon Sep 17 00:00:00 2001 From: Danylo Kuvshynov Date: Wed, 15 Feb 2023 14:09:22 -0600 Subject: [PATCH] Fix https://github.com/alcounit/selenosis/issues/52 --- handlers.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/handlers.go b/handlers.go index 40110f4..893724a 100644 --- a/handlers.go +++ b/handlers.go @@ -44,11 +44,12 @@ type req struct { *http.Request } -func (r req) buildURL(hostPort, sessionID string) *sess { - host, port, _ := net.SplitHostPort(hostPort) +func (r req) buildURL(sessionID string) *sess { + hostPort := r.Context().Value(http.LocalAddrContextKey).(net.Addr).String() + _, port, _ := net.SplitHostPort(hostPort) return &sess{ - url: fmt.Sprintf("http://%s/wd/hub/session/%s", net.JoinHostPort(host, port), sessionID), + url: fmt.Sprintf("http://%s/wd/hub/session/%s", net.JoinHostPort("127.0.0.1", port), sessionID), id: sessionID, } }