Skip to content

Commit 404770f

Browse files
jrmann100claude
andcommitted
fix: respect MUX_BASE_URL env var during login and avoid redundant config read
- Login now checks env-file > process.env.MUX_BASE_URL > default, so interactive login with MUX_BASE_URL set works correctly. - createAuthenticatedMuxClient reads baseUrl from the already-fetched environment instead of calling getMuxBaseUrl() (which would re-read config from disk). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f274010 commit 404770f

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/commands/login.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export const loginCommand = new Command()
8383
);
8484
}
8585

86+
// Resolve base URL: env-file > MUX_BASE_URL env var > default
87+
// Only persist to config if nonstandard
8688
let baseUrl: string | undefined;
8789

8890
if (options.envFile) {
@@ -100,10 +102,7 @@ export const loginCommand = new Command()
100102

101103
tokenId = envVars.MUX_TOKEN_ID;
102104
tokenSecret = envVars.MUX_TOKEN_SECRET;
103-
104-
if (envVars.MUX_BASE_URL && envVars.MUX_BASE_URL !== DEFAULT_BASE_URL) {
105-
baseUrl = envVars.MUX_BASE_URL;
106-
}
105+
baseUrl = envVars.MUX_BASE_URL || process.env.MUX_BASE_URL;
107106
} else {
108107
// Interactive prompts
109108
console.log('Enter your Mux API credentials.');
@@ -120,14 +119,17 @@ export const loginCommand = new Command()
120119
if (!tokenSecret.trim()) {
121120
throw new Error('Token Secret is required');
122121
}
122+
123+
baseUrl = process.env.MUX_BASE_URL;
123124
}
124125

125-
// Validate credentials
126+
// Validate credentials against the resolved base URL (never fall through to config)
127+
const validationUrl = baseUrl || DEFAULT_BASE_URL;
126128
console.log('Validating credentials...');
127129
const validation = await validateCredentials(
128130
tokenId.trim(),
129131
tokenSecret.trim(),
130-
baseUrl || DEFAULT_BASE_URL,
132+
validationUrl,
131133
);
132134

133135
if (!validation.valid) {
@@ -141,7 +143,7 @@ export const loginCommand = new Command()
141143
tokenId: tokenId.trim(),
142144
tokenSecret: tokenSecret.trim(),
143145
environmentId: validation.environmentId,
144-
...(baseUrl && { baseUrl }),
146+
...(baseUrl && baseUrl !== DEFAULT_BASE_URL && { baseUrl }),
145147
});
146148

147149
console.log(

src/lib/mux.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export async function createAuthenticatedMuxClient(): Promise<Mux> {
5656
throw new Error("Not logged in. Please run 'mux login' to authenticate.");
5757
}
5858

59-
const baseURL = await getMuxBaseUrl();
59+
const baseURL =
60+
process.env.MUX_BASE_URL || env.environment.baseUrl || DEFAULT_BASE_URL;
6061

6162
return new Mux({
6263
tokenId: env.environment.tokenId,

0 commit comments

Comments
 (0)