1 import { isBrowser } from './utils';
3 const testHost = 'localhost:8536';
5 const internalHost = process.env.LEMMY_INTERNAL_HOST || testHost; // used for local dev
6 export const externalHost = isBrowser()
7 ? `${window.location.hostname}${
8 ['1234', '1235'].includes(window.location.port)
10 : window.location.port
12 : process.env.LEMMY_EXTERNAL_HOST || testHost;
14 const secure = isBrowser()
15 ? window.location.protocol == 'https:'
18 : process.env.LEMMY_HTTPS == 'true'
22 const host = isBrowser() ? externalHost : internalHost;
24 const httpBase = `http://${host}`; // Don't use secure here
25 export const wsUri = `ws${secure}://${host}/api/v1/ws`;
26 export const httpUri = `${httpBase}/api/v1`;
27 export const pictrsUri = `http${secure}://${host}/pictrs/image`;
29 console.log(`httpbase: ${httpBase}`);
30 console.log(`wsUri: ${wsUri}`);
32 // This is for html tags, don't include port
33 const httpExternalUri = `http${secure}://${externalHost.split(':')[0]}`;
34 export function httpExternalPath(path: string) {
35 return `${httpExternalUri}${path}`;