Skip to content

Commit 26f5bc2

Browse files
Merge pull request #31 from contentstack/CL-1627
fix: fix HPE_INVALID_HEADER_TOKEN error on creating new GitHub project
2 parents e6e6a34 + b7adf1f commit 26f5bc2

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

src/base-command.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import config from './config';
2121
import { GraphqlApiClient, Logger } from './util';
2222
import { getLaunchHubUrl } from './util/common-utility';
23-
import { ConfigType, LogFn, Providers } from './types';
23+
import { ConfigType, LogFn, Providers, GraphqlHeaders } from './types';
2424

2525
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
2626
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
@@ -198,20 +198,27 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
198198
* @memberof BaseCommand
199199
*/
200200
async prepareApiClients(): Promise<void> {
201+
let headers: GraphqlHeaders = {
202+
'X-CS-CLI': this.context.analyticsInfo
203+
}
204+
205+
const { uid, organizationUid } = this.sharedConfig.currentConfig;
206+
207+
if (uid) {
208+
headers['x-project-uid'] = uid;
209+
}
210+
211+
if (organizationUid) {
212+
headers['organization_uid'] = organizationUid;
213+
}
214+
201215
this.apolloClient = await new GraphqlApiClient({
202-
headers: {
203-
'X-CS-CLI': this.context.analyticsInfo,
204-
'x-project-uid': this.sharedConfig.currentConfig.uid,
205-
organization_uid: this.sharedConfig.currentConfig.organizationUid,
206-
},
216+
headers,
207217
baseUrl: this.sharedConfig.manageApiBaseUrl,
208218
}).apolloClient;
219+
209220
this.apolloLogsClient = await new GraphqlApiClient({
210-
headers: {
211-
'X-CS-CLI': this.context.analyticsInfo,
212-
'x-project-uid': this.sharedConfig.currentConfig.uid,
213-
organization_uid: this.sharedConfig.currentConfig.organizationUid,
214-
},
221+
headers,
215222
baseUrl: this.sharedConfig.logsApiBaseUrl,
216223
}).apolloClient;
217224
}

0 commit comments

Comments
 (0)