diff --git a/src/config.ts b/src/config.ts index e6f0d71..dad160e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -24,6 +24,8 @@ class Config implements ConfigInterface { FrontendAPI: string; + FrontendAPIWithCName: string; + BackendAPI: string = DefaultBackendAPI; ShortSessionCookieName: string = DefaultShortSessionCookieName; @@ -32,7 +34,7 @@ class Config implements ConfigInterface { CacheMaxAge: number = DefaultCacheMaxAge; - constructor(projectID: string, apiSecret: string) { + constructor(projectID: string, apiSecret: string, cname?: string) { this.validateProjectID(projectID); this.validateAPISecret(apiSecret); @@ -40,6 +42,7 @@ class Config implements ConfigInterface { this.APISecret = apiSecret; this.Client = DefaultClient; this.FrontendAPI = DefaultFrontendAPI.replace('[projectID]', projectID); + this.FrontendAPIWithCName = cname ?? this.FrontendAPI; } public setFrontendAPI(frontendApi: string): void { diff --git a/src/sdk.ts b/src/sdk.ts index f0e7c5d..43eec13 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -34,7 +34,7 @@ class SDK { this.session = new Session( this.axiosClient, config.ShortSessionCookieName, - config.FrontendAPI, + config.FrontendAPIWithCName, `${config.FrontendAPI}/.well-known/jwks`, config.CacheMaxAge );