1 import { isBrowser } from "./utils";
3 const testHost = "0.0.0.0:8536";
6 (!isBrowser() && process.env.LEMMY_UI_LEMMY_INTERNAL_HOST) || testHost; // used for local dev
7 export let externalHost: string;
15 typeof window.lemmyConfig !== "undefined" ? window.lemmyConfig : {};
17 externalHost = `${window.location.hostname}${
18 ["1234", "1235"].includes(window.location.port)
20 : window.location.port == ""
22 : `:${window.location.port}`
26 wsHost = lemmyConfig.wsHost || host;
27 secure = window.location.protocol == "https:" ? "s" : "";
30 externalHost = process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST || testHost;
32 wsHost = process.env.LEMMY_UI_LEMMY_WS_HOST || externalHost;
33 secure = process.env.LEMMY_UI_HTTPS == "true" ? "s" : "";
36 export const httpBaseInternal = `http://${host}`; // Don't use secure here
37 export const httpBase = `http${secure}://${host}`;
38 export const wsUriBase = `ws${secure}://${wsHost}`;
39 export const wsUri = `${wsUriBase}/api/v3/ws`;
40 export const pictrsUri = `${httpBase}/pictrs/image`;
41 export const isHttps = secure.endsWith("s");
43 console.log(`httpbase: ${httpBase}`);
44 console.log(`wsUri: ${wsUri}`);
45 console.log(`isHttps: ${isHttps}`);
47 // This is for html tags, don't include port
48 const httpExternalUri = `http${secure}://${externalHost.split(":")[0]}`;
49 export function httpExternalPath(path: string) {
50 return `${httpExternalUri}${path}`;