2020-09-09 22:07:58 +00:00
|
|
|
import { isBrowser } from './utils';
|
2020-09-06 16:15:25 +00:00
|
|
|
|
2020-09-10 16:39:01 +00:00
|
|
|
const nodeHostname = process.env.LEMMY_HOST || 'localhost'; // used for local dev
|
|
|
|
const host = isBrowser() ? window.location.hostname : nodeHostname;
|
2020-09-09 22:07:58 +00:00
|
|
|
const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : '';
|
|
|
|
const port = isBrowser()
|
2020-09-10 16:39:01 +00:00
|
|
|
? window.location.port == '1234' || window.location.port == '1235'
|
2020-09-09 22:07:58 +00:00
|
|
|
? 8536
|
|
|
|
: window.location.port
|
|
|
|
: 8536;
|
2020-09-06 16:15:25 +00:00
|
|
|
const endpoint = `${host}:${port}`;
|
2020-09-09 22:07:58 +00:00
|
|
|
|
|
|
|
export const wsUri = `ws${secure}://${endpoint}/api/v1/ws`;
|
|
|
|
export const httpUri = `http${secure}://${endpoint}/api/v1`;
|