mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 09:28:11 +00:00
Url configs
This commit is contained in:
1 parent
4637cda65d
commit
e52203fff7
4 files changed
+98
-2
No files matched your search
@@ -0,0 +1,22 @@
|
||||
|
||||
export enum StorytellerDomain {
|
||||
// Development
|
||||
Localhost,
|
||||
JungleHorse,
|
||||
// Production
|
||||
Storyteller,
|
||||
}
|
||||
|
||||
//// Web-accessible, user-facing (non-API) domain names and subdomains
|
||||
//export enum StorytellerSubdomain {
|
||||
// // Development
|
||||
// Localhost = "localhost",
|
||||
// JungleHorse = "jungle.horse",
|
||||
// JungleHorseObs = "obs.jungle.horse",
|
||||
// JungleHorseCreate = "jungle.horse",
|
||||
// // TODO: JungleHorseCreate = "create.jungle.horse",
|
||||
// // Storyteller
|
||||
// Storyteller = "storyteller.io",
|
||||
// StorytellerCreate = "create.storyteller.io",
|
||||
// StorytellerObs = "obs.storyteller.io",
|
||||
//}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
// Web-accessible, user-facing (non-API) domain names
|
||||
export enum FakeYouSiteDomain {
|
||||
// Development
|
||||
Localhost = "localhost",
|
||||
LocalhostDocs = "localhost:3000",
|
||||
JungleHorse = "jungle.horse",
|
||||
JungleHorseDocs = "jungle.horse:3000",
|
||||
// FakeYou
|
||||
FakeYou = "fakeyou.com",
|
||||
FakeYouDocs = "docs.fakeyou.com",
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
import { StorytellerDomain } from "./DomainNames";
|
||||
|
||||
export class StorytellerUrlConfig {
|
||||
private domain: StorytellerDomain;
|
||||
private useSsl: boolean;
|
||||
|
||||
constructor() {
|
||||
let useSsl = true;
|
||||
let domain = StorytellerDomain.Storyteller;
|
||||
|
||||
if (document.location.host.includes("localhost")) {
|
||||
// NB: `localhost` seems to have problems with cookies.
|
||||
// I've added jungle.horse as a localhost mapped domain in /etc/hosts,
|
||||
// This should be the preferred mechanism for local testing.
|
||||
domain = StorytellerDomain.Localhost;
|
||||
useSsl = document.location.protocol === 'https:';
|
||||
} else if (document.location.host.includes("jungle.horse")) {
|
||||
// NB: Also local dev. More friendly with cookies, CORS, etc.
|
||||
domain = StorytellerDomain.JungleHorse;
|
||||
useSsl = document.location.protocol === 'https:';
|
||||
}
|
||||
|
||||
this.domain = domain;
|
||||
this.useSsl = useSsl;
|
||||
}
|
||||
|
||||
twitchOauthEnrollRedirect() : string {
|
||||
return `${this.getScheme()}://${this.getApiHost()}/twitch/oauth_enroll_redirect`;
|
||||
}
|
||||
|
||||
// =============== API HOSTS ===============
|
||||
|
||||
private getApiHost() : string {
|
||||
switch (this.domain) {
|
||||
case StorytellerDomain.Localhost:
|
||||
return 'localhost';
|
||||
case StorytellerDomain.JungleHorse:
|
||||
return 'api.jungle.horse';
|
||||
case StorytellerDomain.Storyteller:
|
||||
default:
|
||||
return 'api.storyteller.io';
|
||||
}
|
||||
}
|
||||
|
||||
private getObsHost() : string {
|
||||
switch (this.domain) {
|
||||
case StorytellerDomain.Localhost:
|
||||
return 'localhost';
|
||||
case StorytellerDomain.JungleHorse:
|
||||
return 'obs.jungle.horse';
|
||||
case StorytellerDomain.Storyteller:
|
||||
default:
|
||||
return 'obs.storyteller.io';
|
||||
}
|
||||
}
|
||||
|
||||
// =============== HTTP SCHEME ===============
|
||||
|
||||
private getScheme(): string {
|
||||
return this.useSsl ? 'https' : 'http';
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,10 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faCogs, faVideo } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faDiscord, faTwitch } from '@fortawesome/free-brands-svg-icons';
|
||||
import { DiscordLink } from '@storyteller/components/src/elements/DiscordLink';
|
||||
import { StorytellerUrlConfig } from '@storyteller/components/src/urls/StorytellerUrlConfig';
|
||||
|
||||
function LoggedInIndex() {
|
||||
//const oauthUrl = `https://api.jungle.horse/twitch/oauth_enroll_redirect`;
|
||||
const oauthUrl = `https://api.storyteller.io/twitch/oauth_enroll_redirect`;
|
||||
const oauthUrl = new StorytellerUrlConfig().twitchOauthEnrollRedirect();
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in new issue
Block a user