From 1e98f03bd79a85e789b505ebb375de8d7c8c94a0 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Sat, 20 Aug 2022 13:47:57 +0100 Subject: [PATCH 1/2] Serve builder preview via server to fix dependency on third party cookies --- hosting/nginx.dev.conf.hbs | 4 + .../[screenId]/_components/AppPreview.svelte | 9 +- .../[screenId]/_components/iframeTemplate.js | 104 ------------------ .../src/api/controllers/static/index.ts | 17 +++ .../controllers/static/templates/preview.hbs | 103 +++++++++++++++++ packages/server/src/api/routes/static.ts | 1 + .../src/api/routes/tests/static.spec.js | 26 +++-- 7 files changed, 145 insertions(+), 119 deletions(-) delete mode 100644 packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/iframeTemplate.js create mode 100644 packages/server/src/api/controllers/static/templates/preview.hbs 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 @@