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 window.location.port == '1234' || window.location.port == '1235'
10 : window.location.port
12 : process.env.LEMMY_EXTERNAL_HOST || testHost;
14 // ? window.location.port == '1234' || window.location.port == '1235'
15 const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : '';
17 const host = isBrowser() ? externalHost : internalHost;
19 const httpBase = `http${secure}://${host}`;
20 export const wsUri = `ws${secure}://${host}/api/v1/ws`;
21 export const httpUri = `${httpBase}/api/v1`;
22 const httpExternalUri = `http${secure}://${externalHost}`;
23 export const pictrsUri = `${httpBase}/pictrs/image`;
25 console.log(`Internal host: ${internalHost}`);
26 console.log(`External host: ${externalHost}`);
28 export function httpExternalPath(path: string) {
29 return `${httpExternalUri}${path}`;
32 // export const httpUri = `http${secure}://${endpoint}/api/v1`;
33 // export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`;
35 // const host = isBrowser() ? window.location.hostname : localHostname;
36 // const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : '';
37 // const port = isBrowser()
38 // ? window.location.port == '1234' || window.location.port == '1235'
40 // : window.location.port
42 // const endpoint = `${host}:${port}`;
44 // export const wsUri = `ws${secure}://${endpoint}/api/v1/ws`;
45 // export const httpUri = `http${secure}://${endpoint}/api/v1`;
46 // export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`;