fakeyou domain support

This commit is contained in:
Brandon Thomas committed 2021-09-28 04:14:25 -04:00
1 parent 69aa36cfc2
commit bc8fc1cebf
1 file changed
+37 -8
+37 -8
View File
@@ -15,17 +15,37 @@ export interface ListW2lInferenceResultsForUserArgs {
limit?: number
};
enum Domain {
Localhost,
JungleHorse,
Vocodes,
FakeYou,
Unknown,
}
class ApiConfig {
isLocalDev: boolean;
domain: Domain;
useSsl: boolean;
constructor() {
if (document.location.host.includes("localhost") ||
document.location.host.includes("jungle.horse")) {
this.isLocalDev = true;
} else {
this.isLocalDev = false;
let useSsl = true;
let domain = Domain.Unknown;
if (document.location.host.includes("localhost")) {
domain = Domain.Localhost;
useSsl = false;
} else if (document.location.host.includes("jungle.horse")) {
domain = Domain.JungleHorse;
useSsl = false;
} else if (document.location.host.includes("vo.codes")) {
domain = Domain.Vocodes;
} else if (document.location.host.includes("fakeyou.com")) {
domain = Domain.FakeYou;
}
this.domain = domain;
this.useSsl = useSsl;
}
speakEndpoint() : string {
@@ -275,13 +295,22 @@ class ApiConfig {
}
private getScheme() : string {
return this.isLocalDev ? "http" : "https";
return this.useSsl ? "https" : "http";
}
private getNewApiHost() : string {
// NB: `localhost` seems to have problems with cookies.
// I've added jungle.horse as a localhost mapped domain in /etc/hosts
return this.isLocalDev ? "api.jungle.horse" : "api.vo.codes";
switch (this.domain) {
case Domain.Localhost:
case Domain.JungleHorse:
return "api.jungle.horse";
case Domain.Vocodes:
return "api.vo.codes";
case Domain.FakeYou:
case Domain.Unknown:
return "api.fake.you";
}
}
}