Skip to content

Commit 4fdd9d3

Browse files
fix: fallback to main API key when sandbox key is empty
The client now properly falls back to DYNADOT_API_KEY when DYNADOT_SANDBOX_KEY is not set or empty, even in sandbox mode. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent af13e24 commit 4fdd9d3

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

src/client.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,12 @@ class DynadotClient {
6464
constructor(config: ClientConfig = {}) {
6565
const sandbox = config.sandbox ?? process.env.DYNADOT_SANDBOX === 'true';
6666

67-
// Use sandbox key if in sandbox mode and available, otherwise use main API key
67+
// Use sandbox key if in sandbox mode and available, otherwise fall back to main API key
68+
const sandboxKey = process.env.DYNADOT_SANDBOX_KEY;
6869
const apiKey =
69-
config.apiKey ??
70-
(sandbox ? process.env.DYNADOT_SANDBOX_KEY : null) ??
71-
process.env.DYNADOT_API_KEY;
70+
config.apiKey || (sandbox && sandboxKey ? sandboxKey : null) || process.env.DYNADOT_API_KEY;
7271
if (!apiKey) {
73-
throw new Error(
74-
sandbox
75-
? 'Sandbox API key required: provide via config.apiKey, DYNADOT_SANDBOX_KEY, or DYNADOT_API_KEY env var'
76-
: 'API key required: provide via config.apiKey or DYNADOT_API_KEY env var',
77-
);
72+
throw new Error('API key required: provide via config.apiKey or DYNADOT_API_KEY env var');
7873
}
7974

8075
this.apiKey = apiKey;

0 commit comments

Comments
 (0)