From cbcd34e34ea0a204ced8668a17d6438ea2e2b979 Mon Sep 17 00:00:00 2001 From: Meredith Lancaster Date: Mon, 18 Mar 2024 09:23:01 -0600 Subject: [PATCH] set api server based on host Signed-off-by: Meredith Lancaster --- pkg/cmd/attestation/api/client.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/attestation/api/client.go b/pkg/cmd/attestation/api/client.go index 1660fdbb1..b99fa5742 100644 --- a/pkg/cmd/attestation/api/client.go +++ b/pkg/cmd/attestation/api/client.go @@ -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, } }