From a4a26d551fab7874cc5524cfab2c272fc87ec2b3 Mon Sep 17 00:00:00 2001 From: Christian Stoyanov Date: Wed, 25 Jan 2023 10:05:01 +0100 Subject: [PATCH 1/2] feat: set host from opt --- src/keys/get-management-token.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/keys/get-management-token.ts b/src/keys/get-management-token.ts index 2fb0f4f0..e98d11df 100644 --- a/src/keys/get-management-token.ts +++ b/src/keys/get-management-token.ts @@ -14,6 +14,7 @@ export interface GetManagementTokenOptions { environmentId: string keyId?: string reuseToken?: boolean + host?: string } let defaultCache: NodeCache @@ -145,7 +146,7 @@ export const getManagementToken = (privateKey: string, opts: GetManagementTokenO } return createGetManagementToken( createLogger({ filename: __filename }), - createHttpClient(), + createHttpClient({ prefixUrl: opts.host }), defaultCache )(privateKey, opts) } From d1dadc4feaed59568c3f4f871bb55e74c6014352 Mon Sep 17 00:00:00 2001 From: Christian Stoyanov Date: Mon, 13 Feb 2023 09:46:19 +0100 Subject: [PATCH 2/2] fix: only set host if it's not undefined --- src/keys/get-management-token.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/keys/get-management-token.ts b/src/keys/get-management-token.ts index e98d11df..5b065d24 100644 --- a/src/keys/get-management-token.ts +++ b/src/keys/get-management-token.ts @@ -144,9 +144,11 @@ export const getManagementToken = (privateKey: string, opts: GetManagementTokenO if ((opts.reuseToken || opts.reuseToken === undefined) && !defaultCache) { defaultCache = new NodeCache() } + const httpClientOpts = typeof opts.host !== 'undefined' ? { prefixUrl: opts.host } : {} + return createGetManagementToken( createLogger({ filename: __filename }), - createHttpClient({ prefixUrl: opts.host }), + createHttpClient(httpClientOpts), defaultCache )(privateKey, opts) }