Skip to content

Commit c77cfa4

Browse files
shirgoldbirdclaude
andcommitted
fix: don't let persisted config override key-based auto-detection
init, auth set-key, and createDeepLClient were passing the config's api.baseUrl to HttpClient, which overrode auto-detection for users with old config files that had the pro URL hardcoded. - init/auth: validate new keys with auto-detected endpoint only - createDeepLClient: stop passing usePro (redundant with auto-detect) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e46f3a4 commit c77cfa4

3 files changed

Lines changed: 5 additions & 12 deletions

File tree

src/cli/commands/auth.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ export class AuthCommand {
2727
// Note: No format validation - let the API determine if the key is valid
2828
// This supports production keys (:fx suffix), free keys, and test keys
2929
try {
30-
// Use configured API endpoint for validation
31-
const baseUrl = this.config.getValue<string>('api.baseUrl');
32-
const usePro = this.config.getValue<boolean>('api.usePro');
33-
34-
const client = new DeepLClient(apiKey, { baseUrl, usePro });
30+
// Let the client auto-detect the endpoint from the key suffix
31+
const client = new DeepLClient(apiKey);
3532
await client.getUsage(); // Test API key validity
3633
} catch (error) {
3734
if (error instanceof Error) {

src/cli/commands/init.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ export class InitCommand {
3939
Logger.output('\nValidating API key...');
4040

4141
const { DeepLClient } = await import('../../api/deepl-client.js');
42-
const baseUrl = this.config.getValue<string>('api.baseUrl');
43-
const usePro = this.config.getValue<boolean>('api.usePro');
44-
const client = new DeepLClient(apiKey.trim(), { baseUrl, usePro });
42+
const client = new DeepLClient(apiKey.trim());
4543
await client.getUsage();
4644

4745
this.config.set('auth.apiKey', apiKey.trim());

src/cli/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,14 @@ async function createDeepLClient(overrideBaseUrl?: string): Promise<DeepLClient>
100100
}
101101

102102
const baseUrl = overrideBaseUrl ?? configService.getValue<string>('api.baseUrl');
103-
const usePro = configService.getValue<boolean>('api.usePro');
104103

105104
if (baseUrl) {
106105
const { validateApiUrl } = await import('../utils/validate-url.js');
107106
validateApiUrl(baseUrl);
108107
}
109108

110109
const { DeepLClient: Client } = await import('../api/deepl-client.js');
111-
return new Client(key, { baseUrl, usePro });
110+
return new Client(key, { baseUrl });
112111
}
113112

114113
// Create program
@@ -198,9 +197,8 @@ function getApiKeyAndOptions(): { apiKey: string; options: import('../api/http-c
198197
if (baseUrl) {
199198
validateApiUrl(baseUrl);
200199
}
201-
const usePro = configService.getValue<boolean>('api.usePro');
202200

203-
return { apiKey: key, options: { baseUrl, usePro } };
201+
return { apiKey: key, options: { baseUrl } };
204202
}
205203

206204
// Shared dependencies passed to register functions

0 commit comments

Comments
 (0)