diff --git a/hosting/nginx.dev.conf.hbs b/hosting/nginx.dev.conf.hbs index 9398b7e719..e08516c9d3 100644 --- a/hosting/nginx.dev.conf.hbs +++ b/hosting/nginx.dev.conf.hbs @@ -62,6 +62,10 @@ http { proxy_pass http://{{ address }}:4001; } + location /preview { + proxy_pass http://{{ address }}:4001; + } + location /builder { proxy_pass http://{{ address }}:3000; rewrite ^/builder(.*)$ /builder/$1 break; diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte index 8e4e172a0d..9f81effd1d 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPreview.svelte @@ -8,7 +8,6 @@ selectedLayout, currentAsset, } from "builderStore" - import iframeTemplate from "./iframeTemplate" import ConfirmDialog from "components/common/ConfirmDialog.svelte" import { ProgressCircle, @@ -40,12 +39,6 @@ BUDIBASE: "type", } - // Construct iframe template - $: template = iframeTemplate.replace( - /\{\{ CLIENT_LIB_PATH }}/, - $store.clientLibPath - ) - const placeholderScreen = new Screen() .name("Screen Placeholder") .route("/") @@ -298,7 +291,7 @@ - -` diff --git a/packages/server/src/api/controllers/static/index.ts b/packages/server/src/api/controllers/static/index.ts index c4d51293b5..bec06d0bf0 100644 --- a/packages/server/src/api/controllers/static/index.ts +++ b/packages/server/src/api/controllers/static/index.ts @@ -102,6 +102,7 @@ export const deleteObjects = async function (ctx: any) { } export const serveApp = async function (ctx: any) { + console.log("SERVE APP") const db = getAppDB({ skip_setup: true }) const appInfo = await db.get(DocumentType.APP_METADATA) let appId = getAppId() @@ -128,6 +129,22 @@ export const serveApp = async function (ctx: any) { } } +export const serveBuilderPreview = async function (ctx: any) { + const db = getAppDB({ skip_setup: true }) + const appInfo = await db.get(DocumentType.APP_METADATA) + + if (!env.isJest()) { + let appId = getAppId() + const previewHbs = loadHandlebarsFile(`${__dirname}/templates/preview.hbs`) + ctx.body = await processString(previewHbs, { + clientLibPath: clientLibraryPath(appId, appInfo.version, ctx), + }) + } else { + // just return the app info for jest to assert on + ctx.body = { ...appInfo, builderPreview: true } + } +} + export const serveClientLibrary = async function (ctx: any) { return send(ctx, "budibase-client.js", { root: join(NODE_MODULES_PATH, "@budibase", "client", "dist"), diff --git a/packages/server/src/api/controllers/static/templates/preview.hbs b/packages/server/src/api/controllers/static/templates/preview.hbs new file mode 100644 index 0000000000..28908df507 --- /dev/null +++ b/packages/server/src/api/controllers/static/templates/preview.hbs @@ -0,0 +1,103 @@ + +
+