Browse Source

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.

gh-pages
mike12345567 6 years ago
parent
commit
9aca697bee
  1. 2
      hosting/docker-compose.yaml
  2. 2
      hosting/hosting.properties
  3. 46
      packages/builder/src/components/start/CreateAppModal.svelte
  4. 6
      packages/server/src/api/controllers/static/index.js
  5. 2
      packages/server/src/environment.js

2
hosting/docker-compose.yaml

@ -11,9 +11,7 @@ services:
BUDIBASE_ENVIRONMENT: ${BUDIBASE_ENVIRONMENT} BUDIBASE_ENVIRONMENT: ${BUDIBASE_ENVIRONMENT}
LOGO_URL: ${LOGO_URL} LOGO_URL: ${LOGO_URL}
PORT: 4002 PORT: 4002
HOSTING_URL: ${HOSTING_URL}
JWT_SECRET: ${JWT_SECRET} JWT_SECRET: ${JWT_SECRET}
PROXY_PORT: ${MAIN_PORT}
depends_on: depends_on:
- worker-service - worker-service

2
hosting/hosting.properties

@ -6,9 +6,7 @@ MAIN_PORT=10000
HOSTING_KEY=budibase HOSTING_KEY=budibase
# This section contains customisation options # This section contains customisation options
HOSTING_URL=http://localhost
LOGO_URL=https://logoipsum.com/logo/logo-15.svg LOGO_URL=https://logoipsum.com/logo/logo-15.svg
HOSTING_URL=http://localhost
# This section contains all secrets pertaining to the system # This section contains all secrets pertaining to the system
# These should be updated # These should be updated

46
packages/builder/src/components/start/CreateAppModal.svelte

@ -29,6 +29,7 @@
let lastApiKey let lastApiKey
let fetchApiKeyPromise let fetchApiKeyPromise
const validateApiKey = async apiKey => { const validateApiKey = async apiKey => {
if (isApiKeyValid) return true
if (!apiKey) return false if (!apiKey) return false
// make sure we only fetch once, unless API Key is changed // make sure we only fetch once, unless API Key is changed
@ -45,27 +46,31 @@
return isApiKeyValid 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 submitting = false
let errors = {} let errors = {}
let validationErrors = {} let validationErrors = {}
let validationSchemas = [ let validationSchemas = [
{ apiValidation,
apiKey: string() infoValidation,
.required("Please enter your API key.") userValidation,
.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."),
},
] ]
function buildStep(component) { function buildStep(component) {
@ -82,9 +87,12 @@
let hostingInfo = await hostingStore.actions.fetch() let hostingInfo = await hostingStore.actions.fetch()
// re-init the steps based on whether self hosting or cloud hosted // re-init the steps based on whether self hosting or cloud hosted
if (hostingInfo.type === "self") { if (hostingInfo.type === "self") {
isApiKeyValid = true
steps = [buildStep(Info), buildStep(User)] steps = [buildStep(Info), buildStep(User)]
} else { validationSchemas = [
steps = [buildStep(API), buildStep(Info), buildStep(User)] infoValidation,
userValidation,
]
} }
}) })

6
packages/server/src/api/controllers/static/index.js

@ -19,8 +19,8 @@ const env = require("../../../environment")
function objectStoreUrl() { function objectStoreUrl() {
if (env.SELF_HOSTED) { if (env.SELF_HOSTED) {
// TODO: need a better way to handle this, probably reverse proxy // can use a relative url for this as all goes through the proxy (this is hosted in minio)
return `${env.HOSTING_URL}:${env.PROXY_PORT}/app-assets/assets` return `/app-assets/assets`
} else { } else {
return "https://cdn.app.budi.live/assets" return "https://cdn.app.budi.live/assets"
} }
@ -157,7 +157,7 @@ exports.serveApp = async function(ctx) {
title: appInfo.name, title: appInfo.name,
production: env.CLOUD, production: env.CLOUD,
appId: ctx.params.appId, appId: ctx.params.appId,
objectStoreUrl: objectStoreUrl(ctx.params.appId), objectStoreUrl: objectStoreUrl(),
}) })
const template = handlebars.compile( const template = handlebars.compile(

2
packages/server/src/environment.js

@ -37,8 +37,6 @@ module.exports = {
DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL, DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL,
LOCAL_TEMPLATES: process.env.LOCAL_TEMPLATES, LOCAL_TEMPLATES: process.env.LOCAL_TEMPLATES,
// self hosting features // self hosting features
HOSTING_URL: process.env.HOSTING_URL,
PROXY_PORT: process.env.PROXY_PORT,
LOGO_URL: process.env.LOGO_URL, LOGO_URL: process.env.LOGO_URL,
_set(key, value) { _set(key, value) {
process.env[key] = value process.env[key] = value

Loading…
Cancel
Save