From 1c1ffcd0cb182f742975a980569a5d5cd7c7ebb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vlada=20Petrovi=C4=87?= Date: Thu, 19 Mar 2026 13:50:13 +0100 Subject: [PATCH] feat: support --api-url flag and DATABOX_API_URL env var in auth login The login command was missing the ability to set a custom API base URL, making it impossible to authenticate against non-production environments. The flag is hidden and won't appear in the help output. --- src/commands/auth/login.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/commands/auth/login.ts b/src/commands/auth/login.ts index 7fb9e56..9b1bcb1 100644 --- a/src/commands/auth/login.ts +++ b/src/commands/auth/login.ts @@ -16,12 +16,18 @@ export default class Login extends Command { 'api-key': Flags.string({ description: 'API key (if not provided, you will be prompted)', }), + 'api-url': Flags.string({ + description: 'Override the API base URL', + env: 'DATABOX_API_URL', + hidden: true, + }), } async run(): Promise { const {flags} = await this.parse(Login) let apiKey = flags['api-key'] + const apiUrl = flags['api-url'] if (!apiKey) { apiKey = await prompt('Enter your API key', {mask: true}) @@ -32,10 +38,11 @@ export default class Login extends Command { } const existingConfig = loadConfig() - saveConfig({...existingConfig, apiKey}) + const baseUrl = apiUrl ?? existingConfig.apiUrl + saveConfig({...existingConfig, apiKey, apiUrl: baseUrl}) try { - const client = new ApiClient({apiKey, baseUrl: existingConfig.apiUrl}) + const client = new ApiClient({apiKey, baseUrl}) await client.get('/v1/auth/validate-key') this.log('Authenticated successfully.') } catch {