Fixing up settings to only take the one URL now, the main hosting URL.

This commit is contained in:
mike12345567 2021-01-06 10:59:10 +00:00
parent 49f56ebd53
commit e25f64da71
2 changed files with 16 additions and 20 deletions

View File

@ -42,10 +42,7 @@
</p> </p>
<Toggle thin text="Self hosted" bind:checked={selfhosted} /> <Toggle thin text="Self hosted" bind:checked={selfhosted} />
{#if selfhosted} {#if selfhosted}
<Input bind:value={hostingInfo.appUrl} label="Apps URL" /> <Input bind:value={hostingInfo.hostingUrl} label="Apps URL" />
<Input bind:value={hostingInfo.workerUrl} label="Workers URL" />
<Input bind:value={hostingInfo.minioUrl} label="MINIO URL" />
<Input bind:value={hostingInfo.couchUrl} label="CouchDB URL" />
<Toggle thin text="HTTPS" bind:checked={hostingInfo.useHttps} /> <Toggle thin text="HTTPS" bind:checked={hostingInfo.useHttps} />
{/if} {/if}
</ModalContent> </ModalContent>

View File

@ -5,6 +5,14 @@ function getProtocol(hostingInfo) {
return hostingInfo.useHttps ? "https://" : "http://" return hostingInfo.useHttps ? "https://" : "http://"
} }
async function getURLWithPath(pathIfSelfHosted) {
const hostingInfo = await exports.getHostingInfo()
const protocol = getProtocol(hostingInfo)
const path =
hostingInfo.type === exports.HostingTypes.SELF ? pathIfSelfHosted : ""
return `${protocol}${hostingInfo.hostingUrl}${path}`
}
exports.HostingTypes = { exports.HostingTypes = {
CLOUD: "cloud", CLOUD: "cloud",
SELF: "self", SELF: "self",
@ -22,10 +30,7 @@ exports.getHostingInfo = async () => {
doc = { doc = {
_id: HOSTING_DOC, _id: HOSTING_DOC,
type: exports.HostingTypes.CLOUD, type: exports.HostingTypes.CLOUD,
appUrl: "app.budi.live", hostingUrl: "app.budi.live",
workerUrl: "",
minioUrl: "",
couchUrl: "",
templatesUrl: "prod-budi-templates.s3-eu-west-1.amazonaws.com", templatesUrl: "prod-budi-templates.s3-eu-west-1.amazonaws.com",
useHttps: true, useHttps: true,
} }
@ -37,30 +42,24 @@ exports.getAppUrl = async appId => {
const hostingInfo = await exports.getHostingInfo() const hostingInfo = await exports.getHostingInfo()
const protocol = getProtocol(hostingInfo) const protocol = getProtocol(hostingInfo)
let url let url
if (hostingInfo.type === "cloud") { if (hostingInfo.type === exports.HostingTypes.CLOUD) {
url = `${protocol}${appId}.${hostingInfo.appUrl}` url = `${protocol}${appId}.${hostingInfo.hostingUrl}`
} else { } else {
url = `${protocol}${hostingInfo.appUrl}` url = `${protocol}${hostingInfo.hostingUrl}/app`
} }
return url return url
} }
exports.getWorkerUrl = async () => { exports.getWorkerUrl = async () => {
const hostingInfo = await exports.getHostingInfo() return getURLWithPath("/worker")
const protocol = getProtocol(hostingInfo)
return `${protocol}${hostingInfo.workerUrl}`
} }
exports.getMinioUrl = async () => { exports.getMinioUrl = async () => {
const hostingInfo = await exports.getHostingInfo() return getURLWithPath("/")
const protocol = getProtocol(hostingInfo)
return `${protocol}${hostingInfo.minioUrl}`
} }
exports.getCouchUrl = async () => { exports.getCouchUrl = async () => {
const hostingInfo = await exports.getHostingInfo() return getURLWithPath("/db")
const protocol = getProtocol(hostingInfo)
return `${protocol}${hostingInfo.couchUrl}`
} }
exports.getTemplatesUrl = async (appId, type, name) => { exports.getTemplatesUrl = async (appId, type, name) => {