apisPort := 3000 req.URL.Scheme = "http" if xPrNumber != "" { req.URL.Host = fmt.Sprintf("api-%s:%d", xPrNumber, apisPort) } else { req.URL.Host = fmt.Sprintf("-api:%d", apisPort) } } rp := &httputil.ReverseProxy{ Director: director, } rp.ServeHTTP(w, req)