Adding https flag. Fixes #7

This commit is contained in:
Dessalines 2020-09-11 21:37:27 -05:00
parent 89d15c9d09
commit 8dd3697d38
1 changed files with 9 additions and 22 deletions

View File

@ -11,36 +11,23 @@ export const externalHost = isBrowser()
}`
: process.env.LEMMY_EXTERNAL_HOST || testHost;
// ? window.location.port == '1234' || window.location.port == '1235'
const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : '';
const secure = isBrowser()
? window.location.protocol == 'https:'
? 's'
: ''
: process.env.LEMMY_HTTPS == 'true'
? 's'
: '';
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`;
const httpExternalUri = `http${secure}://${externalHost}`;
export const pictrsUri = `${httpBase}/pictrs/image`;
console.log(`Internal host: ${internalHost}`);
console.log(`External host: ${externalHost}`);
// This is for html tags, don't include port
const httpExternalUri = `http${secure}://${externalHost.split(':')[0]}`;
export function httpExternalPath(path: string) {
return `${httpExternalUri}${path}`;
}
// export const httpUri = `http${secure}://${endpoint}/api/v1`;
// export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`;
// const host = isBrowser() ? window.location.hostname : localHostname;
// const secure = isBrowser() && window.location.protocol == 'https:' ? 's' : '';
// const port = isBrowser()
// ? window.location.port == '1234' || window.location.port == '1235'
// ? 8536
// : window.location.port
// : 8536;
// const endpoint = `${host}:${port}`;
//
// export const wsUri = `ws${secure}://${endpoint}/api/v1/ws`;
// export const httpUri = `http${secure}://${endpoint}/api/v1`;
// export const pictrsUri = `http${secure}://${endpoint}/pictrs/image`;