diff --git a/hosting/envoy.dev.yaml b/hosting/envoy.dev.yaml
index e12bc2c0e0..4a5cd4b892 100644
--- a/hosting/envoy.dev.yaml
+++ b/hosting/envoy.dev.yaml
@@ -26,6 +26,14 @@ static_resources:
cluster: redis-service
prefix_rewrite: "/"
+ - match: { prefix: "/api/" }
+ route:
+ cluster: server-dev
+
+ - match: { prefix: "/builder/" }
+ route:
+ cluster: builder-dev
+
# minio is on the default route because this works
# best, minio + AWS SDK doesn't handle path proxy
- match: { prefix: "/" }
@@ -77,3 +85,32 @@ static_resources:
socket_address:
address: redis-service
port_value: 6379
+
+ - name: server-dev
+ connect_timeout: 0.25s
+ type: strict_dns
+ lb_policy: round_robin
+ load_assignment:
+ cluster_name: server-dev
+ endpoints:
+ - lb_endpoints:
+ - endpoint:
+ address:
+ socket_address:
+ address: 172.17.0.1
+ port_value: 4001
+
+ - name: builder-dev
+ connect_timeout: 15s
+ type: strict_dns
+ lb_policy: round_robin
+ load_assignment:
+ cluster_name: builder-dev
+ endpoints:
+ - lb_endpoints:
+ - endpoint:
+ address:
+ socket_address:
+ address: 172.17.0.1
+ port_value: 3000
+
diff --git a/package.json b/package.json
index 2ba5a99a93..a23864c108 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"clean": "lerna clean",
"kill-port": "kill-port 4001",
"dev": "yarn run kill-port && lerna link && lerna run --parallel dev:builder --concurrency 1",
+ "dev:nuke": "lerna run --parallel dev:stack:nuke",
"test": "lerna run test",
"lint": "eslint packages",
"lint:fix": "eslint --fix packages",
diff --git a/packages/server/src/api/controllers/application.js b/packages/server/src/api/controllers/application.js
index 00678b85a0..cacde4bb00 100644
--- a/packages/server/src/api/controllers/application.js
+++ b/packages/server/src/api/controllers/application.js
@@ -32,6 +32,7 @@ const { processObject } = require("@budibase/string-templates")
const { getAllApps } = require("../../utilities")
const { USERS_TABLE_SCHEMA } = require("../../constants")
const { getDeployedApps } = require("../../utilities/builder/hosting")
+const { clientLibraryPath } = require("../../utilities")
const URL_REGEX_SLASH = /\/|\\/g
@@ -142,6 +143,7 @@ exports.fetchAppPackage = async function(ctx) {
application,
screens,
layouts,
+ clientLibPath: clientLibraryPath(ctx.params.appId),
}
await setBuilderToken(ctx, ctx.params.appId, application.version)
}
diff --git a/packages/server/src/api/controllers/static/index.js b/packages/server/src/api/controllers/static/index.js
index 1bc9c7c6f2..ec3db6bbd3 100644
--- a/packages/server/src/api/controllers/static/index.js
+++ b/packages/server/src/api/controllers/static/index.js
@@ -2,7 +2,6 @@ require("svelte/register")
const send = require("koa-send")
const { resolve, join } = require("../../../utilities/centralPath")
-const { checkSlashesInUrl } = require("../../../utilities")
const fetch = require("node-fetch")
const uuid = require("uuid")
const { prepareUpload } = require("../deploy/utils")
@@ -13,35 +12,10 @@ const CouchDB = require("../../../db")
const setBuilderToken = require("../../../utilities/builder/setBuilderToken")
const { loadHandlebarsFile } = require("../../../utilities/fileSystem")
const env = require("../../../environment")
-const { OBJ_STORE_DIRECTORY } = require("../../../constants")
const fileProcessor = require("../../../utilities/fileSystem/processor")
+const { objectStoreUrl, clientLibraryPath } = require("../../../utilities")
-const BB_CDN = "https://cdn.app.budi.live/assets"
-
-function objectStoreUrl() {
- if (env.SELF_HOSTED) {
- // can use a relative url for this as all goes through the proxy (this is hosted in minio)
- return OBJ_STORE_DIRECTORY
- } else {
- return BB_CDN
- }
-}
-
-function internalObjectStoreUrl() {
- if (env.SELF_HOSTED) {
- return checkSlashesInUrl(env.MINIO_URL + OBJ_STORE_DIRECTORY)
- } else {
- return BB_CDN
- }
-}
-
-async function returnObjectStoreFile(ctx, path) {
- const S3_URL = `${internalObjectStoreUrl()}/${path}`
- const response = await fetch(S3_URL)
- const body = await response.text()
- ctx.set("Content-Type", response.headers.get("Content-Type"))
- ctx.body = body
-}
+const TOP_LEVEL = join(__dirname, "..", "..", "..", "..")
async function checkForSelfHostedURL(ctx) {
// the "appId" component of the URL may actually be a specific self hosted URL
@@ -58,11 +32,7 @@ async function checkForSelfHostedURL(ctx) {
const COMP_LIB_BASE_APP_VERSION = "0.2.5"
exports.serveBuilder = async function(ctx) {
- // TODO: proxy to vite in dev mode
- //if (env.isDev()) {
- // Proxy to vite dev server
- //}
- let builderPath = resolve(__dirname, "../../../../builder")
+ let builderPath = resolve(TOP_LEVEL, "builder")
if (ctx.file === "index.html") {
await setBuilderToken(ctx)
}
@@ -109,7 +79,7 @@ exports.serveApp = async function(ctx) {
title: appInfo.name,
production: env.isProd(),
appId,
- objectStoreUrl: objectStoreUrl(),
+ clientLibPath: clientLibraryPath(appId),
})
const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
@@ -121,20 +91,10 @@ exports.serveApp = async function(ctx) {
})
}
-exports.serveAttachment = async function(ctx) {
- await returnObjectStoreFile(
- ctx,
- join(ctx.user.appId, "attachments", ctx.file)
- )
-}
-
-exports.serveAppAsset = async function(ctx) {
- // TODO: can we just always serve this locally? is anything in S3?
- // if (env.isDev() || env.isTest()) {
- const builderPath = resolve(__dirname, "../../../../builder/assets")
- return send(ctx, ctx.file, { root: builderPath })
- // }
- // await returnObjectStoreFile(ctx, join(ctx.user.appId, "public", ctx.file))
+exports.serveClientLibrary = async function(ctx) {
+ return send(ctx, "budibase-client.js", {
+ root: join(TOP_LEVEL, "node_modules", "@budibase", "client", "dist"),
+ })
}
exports.serveComponentLibrary = async function(ctx) {
diff --git a/packages/server/src/api/controllers/static/templates/BudibaseApp.svelte b/packages/server/src/api/controllers/static/templates/BudibaseApp.svelte
index a787521394..ee819ed8b5 100644
--- a/packages/server/src/api/controllers/static/templates/BudibaseApp.svelte
+++ b/packages/server/src/api/controllers/static/templates/BudibaseApp.svelte
@@ -4,15 +4,7 @@
export let appId
export let production
- export let objectStoreUrl
-
- function publicPath(path) {
- if (production) {
- return `${objectStoreUrl}/${appId}/${path}`
- }
-
- return `/assets/${path}`
- }
+ export let clientLibPath