From b7adf1f8d480ad4e7c9c1a8b2300577656dfd2fd Mon Sep 17 00:00:00 2001 From: Chhavi-Mandowara Date: Wed, 26 Mar 2025 17:44:07 +0530 Subject: [PATCH] fix:fix HPE_INVALID_HEADER_TOKEN error on creating new GitHub project --- src/base-command.ts | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/base-command.ts b/src/base-command.ts index 90c8a69..32527b4 100755 --- a/src/base-command.ts +++ b/src/base-command.ts @@ -20,7 +20,7 @@ import { import config from './config'; import { GraphqlApiClient, Logger } from './util'; import { getLaunchHubUrl } from './util/common-utility'; -import { ConfigType, LogFn, Providers } from './types'; +import { ConfigType, LogFn, Providers, GraphqlHeaders } from './types'; export type Flags = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>; export type Args = Interfaces.InferredArgs; @@ -198,20 +198,27 @@ export abstract class BaseCommand extends Command { * @memberof BaseCommand */ async prepareApiClients(): Promise { + let headers: GraphqlHeaders = { + 'X-CS-CLI': this.context.analyticsInfo + } + + const { uid, organizationUid } = this.sharedConfig.currentConfig; + + if (uid) { + headers['x-project-uid'] = uid; + } + + if (organizationUid) { + headers['organization_uid'] = organizationUid; + } + this.apolloClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.context.analyticsInfo, - 'x-project-uid': this.sharedConfig.currentConfig.uid, - organization_uid: this.sharedConfig.currentConfig.organizationUid, - }, + headers, baseUrl: this.sharedConfig.manageApiBaseUrl, }).apolloClient; + this.apolloLogsClient = await new GraphqlApiClient({ - headers: { - 'X-CS-CLI': this.context.analyticsInfo, - 'x-project-uid': this.sharedConfig.currentConfig.uid, - organization_uid: this.sharedConfig.currentConfig.organizationUid, - }, + headers, baseUrl: this.sharedConfig.logsApiBaseUrl, }).apolloClient; }