set api server based on host

Signed-off-by: Meredith Lancaster <malancas@github.com>
This commit is contained in:
Meredith Lancaster 2024-03-18 09:23:01 -06:00
parent 5cc2f6af1a
commit cbcd34e34e

View file

@ -7,7 +7,9 @@ import (
"strings"
"github.com/cli/cli/v2/api"
"github.com/cli/cli/v2/internal/ghinstance"
ioconfig "github.com/cli/cli/v2/pkg/cmd/attestation/io"
"github.com/cli/go-gh/v2/pkg/auth"
)
const (
@ -32,10 +34,12 @@ type LiveClient struct {
}
func NewLiveClient(hc *http.Client, l *ioconfig.Handler) *LiveClient {
liveAPIClient := api.NewClientFromHTTP(hc)
host, _ := auth.DefaultHost()
serverURL := ghinstance.HostPrefix(host)
return &LiveClient{
api: liveAPIClient,
host: "https://api.github.com",
api: api.NewClientFromHTTP(hc),
host: strings.TrimSuffix(serverURL, "/"),
logger: l,
}
}