Skip to content

Commit

Permalink
get base url as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
rr-bw committed Oct 16, 2023
1 parent 8514d96 commit 8d6eee5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export abstract class EnvironmentService {
setUrlsFromStorage: () => Promise<void>;
setUrls: (urls: Urls) => Promise<Urls>;
getHost: (userId?: string) => Promise<string>;
getRegion: (userId: string) => Promise<string>;
setRegion: (region: Region) => Promise<void>;
getUrls: () => Urls;
isCloud: () => boolean;
Expand Down
9 changes: 5 additions & 4 deletions libs/common/src/platform/services/environment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,21 @@ export class EnvironmentService implements EnvironmentServiceAbstraction {
async getHost(userId?: string) {
const region = await this.getRegion(userId ? userId : null);

let envUrls;

switch (region) {
case Region.US:
return RegionDomain.US;
case Region.EU:
return RegionDomain.EU;
default:
// self-hosted host
return Utils.getHost(
(await this.stateService.getEnvironmentUrls(userId ? { userId: userId } : null)).webVault
);
envUrls = await this.stateService.getEnvironmentUrls(userId ? { userId: userId } : null);
return Utils.getHost(envUrls.webVault || envUrls.base);
}
}

async getRegion(userId?: string) {
private async getRegion(userId?: string) {
return this.stateService.getRegion(userId ? { userId: userId } : null);
}

Expand Down

0 comments on commit 8d6eee5

Please sign in to comment.