From: Dessalines Date: Sat, 12 Sep 2020 02:37:27 +0000 (-0500) Subject: Adding https flag. Fixes #7 X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/%7B?a=commitdiff_plain;h=8dd3697d3816e8527e6634285d2696728737042f;p=lemmy-ui.git Adding https flag. Fixes #7 --- 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`;