Skip to content

Commit

Permalink
Merge pull request #63 from Saif-Shines/keeping-customhost-along-the-…
Browse files Browse the repository at this point in the history
…way-klyst-177

Prevent from dropping customHost headers
  • Loading branch information
VisargD authored May 3, 2024
2 parents 96188b6 + f2ae3ac commit b744d50
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/_types/generalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ApiClientInterface {
Authorization?: string | null | undefined;
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined
}

export interface APIResponseType {
Expand Down
4 changes: 2 additions & 2 deletions src/baseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ export abstract class ApiClient {
portkeyHeaders: Record<string, string>

private fetch: Fetch;
constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug }: ApiClientInterface) {
constructor({ apiKey, baseURL, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost }: ApiClientInterface) {
this.apiKey = apiKey ?? "";
this.baseURL = baseURL ?? "";
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug })
this.customHeaders = createHeaders({ apiKey, config, virtualKey, traceID, metadata, provider, Authorization, cacheForceRefresh, debug, customHost })
this.portkeyHeaders = this.defaultHeaders()
this.fetch = fetch;
this.responseHeaders = {}
Expand Down
4 changes: 4 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class Portkey extends ApiClient {
Authorization?: string;
cacheForceRefresh?: boolean | null | undefined;
debug?: boolean | null | undefined;
customHost?: string | null | undefined;
constructor({
apiKey = readEnv("PORTKEY_API_KEY") ?? null,
baseURL = readEnv("PORTKEY_BASE_URL") ?? null,
Expand All @@ -27,6 +28,7 @@ export class Portkey extends ApiClient {
Authorization,
cacheForceRefresh,
debug,
customHost,
}: ApiClientInterface) {

super({
Expand All @@ -40,6 +42,7 @@ export class Portkey extends ApiClient {
Authorization,
cacheForceRefresh,
debug,
customHost
});

this.apiKey = apiKey;
Expand All @@ -54,6 +57,7 @@ export class Portkey extends ApiClient {
this.metadata = metadata
this.cacheForceRefresh = cacheForceRefresh;
this.debug = debug;
this.customHost = customHost
}

completions: API.Completions = new API.Completions(this);
Expand Down

0 comments on commit b744d50

Please sign in to comment.