Skip to content

Commit 735300e

Browse files
fix: support host without api. prefix by prepending it internally
The CLI now accepts the base domain (e.g. wesfarmers.nullify.ai) as the --host value and internally prepends api. when making API calls. This aligns with the dashboard showing the clean domain in the install command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2bf056d commit 735300e

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎install.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ main() {
161161
if [ -n "$NULLIFY_HOST" ]; then
162162
echo "Run 'nullify auth login' to authenticate."
163163
else
164-
echo "Run 'nullify auth login --host api.<your-instance>.nullify.ai' to get started."
164+
echo "Run 'nullify auth login --host <your-instance>.nullify.ai' to get started."
165165
fi
166166
}
167167

‎internal/api/client.go‎

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎internal/auth/login.go‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func createCLISession(ctx context.Context, host string, port int) (*cliSessionRe
197197
ctx, span := tracer.FromContext(ctx).Start(ctx, "auth.createCLISession")
198198
defer span.End()
199199

200-
url := fmt.Sprintf("https://%s/auth/cli/session", host)
200+
url := fmt.Sprintf("https://%s/auth/cli/session", apiHost(host))
201201

202202
bodyData, err := json.Marshal(map[string]int{"port": port})
203203
if err != nil {
@@ -233,7 +233,7 @@ func fetchCLIToken(ctx context.Context, host string, sessionID string) (*cliToke
233233
ctx, span := tracer.FromContext(ctx).Start(ctx, "auth.fetchCLIToken")
234234
defer span.End()
235235

236-
url := fmt.Sprintf("https://%s/auth/cli/token", host)
236+
url := fmt.Sprintf("https://%s/auth/cli/token", apiHost(host))
237237

238238
bodyData, err := json.Marshal(map[string]string{"session_id": sessionID})
239239
if err != nil {
@@ -269,7 +269,7 @@ func refreshToken(ctx context.Context, host string, refreshTok string) (string,
269269
ctx, span := tracer.FromContext(ctx).Start(ctx, "auth.refreshToken")
270270
defer span.End()
271271

272-
refreshURL := fmt.Sprintf("https://%s/auth/refresh_token?refresh_token=%s", host, url.QueryEscape(refreshTok))
272+
refreshURL := fmt.Sprintf("https://%s/auth/refresh_token?refresh_token=%s", apiHost(host), url.QueryEscape(refreshTok))
273273

274274
req, err := http.NewRequestWithContext(ctx, http.MethodGet, refreshURL, nil)
275275
if err != nil {
@@ -312,6 +312,14 @@ func refreshToken(ctx context.Context, host string, refreshTok string) (string,
312312
return result.AccessToken, nil
313313
}
314314

315+
// apiHost returns the API hostname, prepending "api." if not already present.
316+
func apiHost(host string) string {
317+
if strings.HasPrefix(host, "api.") {
318+
return host
319+
}
320+
return "api." + host
321+
}
322+
315323
func openBrowser(url string) error {
316324
var cmd *exec.Cmd
317325

0 commit comments

Comments
 (0)