1 import { isBrowser } from "./utils/browser/is-browser";
3 const testHost = "0.0.0.0:8536";
5 function getInternalHost() {
7 ? process.env.LEMMY_UI_LEMMY_INTERNAL_HOST ?? testHost
8 : testHost; // used for local dev
11 export function getExternalHost() {
13 ? `${window.location.hostname}${
14 ["1234", "1235"].includes(window.location.port)
16 : window.location.port == ""
18 : `:${window.location.port}`
20 : process.env.LEMMY_UI_LEMMY_EXTERNAL_HOST || testHost;
23 function getSecure() {
26 ? window.location.protocol.includes("https")
27 : process.env.LEMMY_UI_HTTPS === "true"
34 return isBrowser() ? getExternalHost() : getInternalHost();
37 function getBaseLocal(s = "") {
38 return `http${s}://${getHost()}`;
41 export function getHttpBaseInternal() {
42 return getBaseLocal(); // Don't use secure here
45 export function getHttpBaseExternal() {
46 return `http${getSecure()}://${getExternalHost()}`;
49 export function getHttpBase() {
50 return getBaseLocal(getSecure());
53 export function isHttps() {
54 return getSecure() === "s";
57 console.log(`httpbase: ${getHttpBase()}`);
58 console.log(`isHttps: ${isHttps()}`);
60 // This is for html tags, don't include port
61 export function httpExternalPath(path: string) {
62 return `http${getSecure()}://${getExternalHost().replace(