]> Untitled Git - lemmy-ui.git/blob - src/shared/env.ts
Adding opengraph tags. Fixes #5
[lemmy-ui.git] / src / shared / env.ts
1 import { isBrowser } from './utils';
2
3 const testHost = 'localhost:8536';
4
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'
9         ? 8536
10         : window.location.port
11     }`
12   : process.env.LEMMY_EXTERNAL_HOST || testHost;
13
14 //   ? window.location.port == '1234' || window.location.port == '1235'
15 const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : '';
16
17 const host = isBrowser() ? externalHost : internalHost;
18
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`;
24
25 console.log(`Internal host: ${internalHost}`);
26 console.log(`External host: ${externalHost}`);
27
28 export function httpExternalPath(path: string) {
29   return `${httpExternalUri}${path}`;
30 }
31
32 // export const httpUri = `http${secure}://${endpoint}/api/v1`;
33 // export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`;
34
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'
39 //     ? 8536
40 //     : window.location.port
41 //   : 8536;
42 // const endpoint = `${host}:${port}`;
43 //
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`;