From 8dd3697d3816e8527e6634285d2696728737042f Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 11 Sep 2020 21:37:27 -0500 Subject: [PATCH] Adding https flag. Fixes #7 --- src/shared/env.ts | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/shared/env.ts b/src/shared/env.ts index 7347a19..71a6071 100644 --- a/src/shared/env.ts +++ b/src/shared/env.ts @@ -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`; -- 2.44.1