Files
Brandon Thomas 82effe0ce9 add nx for javascript monorepos and move 3d under it (#497)
this required the following:

- downgrading nx react (19 -> 18.2)
- .npmrc credentials for fontawesome
- installing a lot of nx plugins from the vanilla config
- removing kalidokit vendored code and all references to it
2025-04-10 23:15:23 -04:00

45 lines
1.2 KiB
TypeScript

import { GetFrontendEnvironment } from "~/Classes/GetFrontendEnvironment";
/**
* Return the CDN origin (scheme + host + optional port, but no path)
* See: https://web.dev/articles/url-parts
*
* TODO(bt,2025-02-10): Make this easier to configure in development
*/
class CdnHostHelper {
private static instance: CdnHostHelper;
private readonly origin: string;
public static getInstance(): CdnHostHelper {
if (CdnHostHelper.instance !== undefined) {
return CdnHostHelper.instance;
}
const isLocalDev = GetFrontendEnvironment().getIsLocalDev();
let origin;
if (isLocalDev) {
//origin = 'https://pub-c8a4a5bdbdb048f286b77bdf9f786ff2.r2.dev';
origin = 'https://cdn-2.fakeyou.com';
} else {
origin = 'https://cdn-2.fakeyou.com';
}
const instance = new CdnHostHelper(origin);
CdnHostHelper.instance = instance;
return instance;
}
public getOrigin(): string {
return this.origin;
}
private constructor(origin: string) {
this.origin = origin;
}
}
// TODO(bt,2025-02-10): Consolidate all of this logic.
export function GetCdnOrigin() : string {
return CdnHostHelper.getInstance().getOrigin();
}