2020-09-09 22:07:58 +00:00
|
|
|
import { isBrowser } from './utils';
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2020-09-11 18:09:21 +00:00
|
|
|
const testHost = 'localhost:8536';
|
|
|
|
|
|
|
|
const internalHost = process.env.LEMMY_INTERNAL_HOST || testHost; // used for local dev
|
|
|
|
export const externalHost = isBrowser()
|
|
|
|
? `${window.location.hostname}:${
|
|
|
|
window.location.port == '1234' || window.location.port == '1235'
|
|
|
|
? 8536
|
|
|
|
: window.location.port
|
|
|
|
}`
|
|
|
|
: process.env.LEMMY_EXTERNAL_HOST || testHost;
|
|
|
|
|
2020-09-12 02:37:27 +00:00
|
|
|
const secure = isBrowser()
|
|
|
|
? window.location.protocol == 'https:'
|
|
|
|
? 's'
|
|
|
|
: ''
|
|
|
|
: process.env.LEMMY_HTTPS == 'true'
|
|
|
|
? 's'
|
|
|
|
: '';
|
2020-09-11 18:09:21 +00:00
|
|
|
|
|
|
|
const host = isBrowser() ? externalHost : internalHost;
|
|
|
|
|
|
|
|
const httpBase = `http${secure}://${host}`;
|
|
|
|
export const wsUri = `ws${secure}://${host}/api/v1/ws`;
|
|
|
|
export const httpUri = `${httpBase}/api/v1`;
|
|
|
|
export const pictrsUri = `${httpBase}/pictrs/image`;
|
|
|
|
|
2020-09-12 02:37:27 +00:00
|
|
|
// This is for html tags, don't include port
|
|
|
|
const httpExternalUri = `http${secure}://${externalHost.split(':')[0]}`;
|
2020-09-11 18:09:21 +00:00
|
|
|
export function httpExternalPath(path: string) {
|
|
|
|
return `${httpExternalUri}${path}`;
|
|
|
|
}
|