From 85320ea938dd6a1c515a8ff4b94ff1281c60113b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 7 Jan 2021 15:37:41 +0000 Subject: [PATCH] Some minor updates, making template object store URL in self hosting relative so everything just goes through the proxy, and fixing issue with API key being required to create apps in self hosting. --- hosting/docker-compose.yaml | 2 - hosting/hosting.properties | 2 - .../components/start/CreateAppModal.svelte | 46 +++++++++++-------- .../src/api/controllers/static/index.js | 6 +-- packages/server/src/environment.js | 2 - 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml index b0e3941c93..32659ec53c 100644 --- a/hosting/docker-compose.yaml +++ b/hosting/docker-compose.yaml @@ -11,9 +11,7 @@ services: BUDIBASE_ENVIRONMENT: ${BUDIBASE_ENVIRONMENT} LOGO_URL: ${LOGO_URL} PORT: 4002 - HOSTING_URL: ${HOSTING_URL} JWT_SECRET: ${JWT_SECRET} - PROXY_PORT: ${MAIN_PORT} depends_on: - worker-service diff --git a/hosting/hosting.properties b/hosting/hosting.properties index 5907d62819..5776f108e3 100644 --- a/hosting/hosting.properties +++ b/hosting/hosting.properties @@ -6,9 +6,7 @@ MAIN_PORT=10000 HOSTING_KEY=budibase # This section contains customisation options -HOSTING_URL=http://localhost LOGO_URL=https://logoipsum.com/logo/logo-15.svg -HOSTING_URL=http://localhost # This section contains all secrets pertaining to the system # These should be updated diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index 1f27f18aaa..84d1ef7fa3 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -29,6 +29,7 @@ let lastApiKey let fetchApiKeyPromise const validateApiKey = async apiKey => { + if (isApiKeyValid) return true if (!apiKey) return false // make sure we only fetch once, unless API Key is changed @@ -45,27 +46,31 @@ return isApiKeyValid } + const apiValidation = { + apiKey: string() + .required("Please enter your API key.") + .test("valid-apikey", "This API key is invalid", validateApiKey), + } + const infoValidation = { + applicationName: string().required("Your application must have a name."), + } + const userValidation = { + email: string() + .email() + .required("Your application needs a first user."), + password: string().required( + "Please enter a password for your first user." + ), + roleId: string().required("You need to select a role for your user."), + } + let submitting = false let errors = {} let validationErrors = {} let validationSchemas = [ - { - apiKey: string() - .required("Please enter your API key.") - .test("valid-apikey", "This API key is invalid", validateApiKey), - }, - { - applicationName: string().required("Your application must have a name."), - }, - { - email: string() - .email() - .required("Your application needs a first user."), - password: string().required( - "Please enter a password for your first user." - ), - roleId: string().required("You need to select a role for your user."), - }, + apiValidation, + infoValidation, + userValidation, ] function buildStep(component) { @@ -82,9 +87,12 @@ let hostingInfo = await hostingStore.actions.fetch() // re-init the steps based on whether self hosting or cloud hosted if (hostingInfo.type === "self") { + isApiKeyValid = true steps = [buildStep(Info), buildStep(User)] - } else { - steps = [buildStep(API), buildStep(Info), buildStep(User)] + validationSchemas = [ + infoValidation, + userValidation, + ] } }) diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js index a13ab7ac41..52e12d92e7 100644 --- a/packages/server/src/api/controllers/static/index.js +++ b/packages/server/src/api/controllers/static/index.js @@ -19,8 +19,8 @@ const env = require("../../../environment") function objectStoreUrl() { if (env.SELF_HOSTED) { - // TODO: need a better way to handle this, probably reverse proxy - return `${env.HOSTING_URL}:${env.PROXY_PORT}/app-assets/assets` + // can use a relative url for this as all goes through the proxy (this is hosted in minio) + return `/app-assets/assets` } else { return "https://cdn.app.budi.live/assets" } @@ -157,7 +157,7 @@ exports.serveApp = async function(ctx) { title: appInfo.name, production: env.CLOUD, appId: ctx.params.appId, - objectStoreUrl: objectStoreUrl(ctx.params.appId), + objectStoreUrl: objectStoreUrl(), }) const template = handlebars.compile( diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 9d1bccf7c1..8e129913fd 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -37,8 +37,6 @@ module.exports = { DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL, LOCAL_TEMPLATES: process.env.LOCAL_TEMPLATES, // self hosting features - HOSTING_URL: process.env.HOSTING_URL, - PROXY_PORT: process.env.PROXY_PORT, LOGO_URL: process.env.LOGO_URL, _set(key, value) { process.env[key] = value