Support http:// hosts in CLI client for local development

The CLI client was hardcoding https:// scheme, which prevents local dev with http://localhost. Add support for bare hostnames (auto-prepend https) while preserving http:// and https:// prefixes when explicitly provided.

Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
Bryan Frimin
2026-03-16 23:32:02 +01:00
parent 46635e7f04
commit 8819b69d2d

View File

@@ -98,7 +98,12 @@ func (c *Client) DoRaw(
return nil, fmt.Errorf("cannot marshal GraphQL request: %w", err)
}
url := fmt.Sprintf("https://%s%s", c.host, c.endpoint)
host := c.host
if !strings.HasPrefix(host, "http://") && !strings.HasPrefix(host, "https://") {
host = "https://" + host
}
url := fmt.Sprintf("%s%s", host, c.endpoint)
req, err := http.NewRequest(http.MethodPost, url, bytes.NewReader(body))
if err != nil {
return nil, fmt.Errorf("cannot create HTTP request: %w", err)