From b033831c1c14b9d57bb31400400d4fd61bc1e0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 14 Oct 2022 09:01:50 +0200 Subject: [PATCH 1/4] :bug: Fix `BASE_PATH` for Vite dev mode --- packages/editor-ui/src/router.ts | 3 +-- packages/editor-ui/src/shims.d.ts | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/editor-ui/src/router.ts b/packages/editor-ui/src/router.ts index 24359f0d45651..3b84c041a08f1 100644 --- a/packages/editor-ui/src/router.ts +++ b/packages/editor-ui/src/router.ts @@ -55,8 +55,7 @@ function getTemplatesRedirect(store: Store) { const router = new Router({ mode: 'history', - // @ts-ignore - base: window.BASE_PATH ?? '/', + base: window.BASE_PATH === '/{{BASE_PATH}}/' ? '/' : window.BASE_PATH, scrollBehavior(to, from, savedPosition) { // saved position == null means the page is NOT visited from history (back button) if (savedPosition === null && to.name === VIEWS.TEMPLATES && to.meta) { diff --git a/packages/editor-ui/src/shims.d.ts b/packages/editor-ui/src/shims.d.ts index 467ca274f144d..eb1c83fcddccb 100644 --- a/packages/editor-ui/src/shims.d.ts +++ b/packages/editor-ui/src/shims.d.ts @@ -5,6 +5,10 @@ declare module 'markdown-it-emoji'; declare module 'markdown-it-task-lists'; declare global { + interface Window { + BASE_PATH: string; + } + namespace JSX { // tslint:disable no-empty-interface interface Element extends VNode {} From 634064bd27cfe256637b0557c35eec24ab8e71aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 14 Oct 2022 09:30:18 +0200 Subject: [PATCH 2/4] don't use the string `/{{BASE_PATH}}/` as it gets replaces in build --- packages/editor-ui/src/router.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/editor-ui/src/router.ts b/packages/editor-ui/src/router.ts index 3b84c041a08f1..ca2944998a923 100644 --- a/packages/editor-ui/src/router.ts +++ b/packages/editor-ui/src/router.ts @@ -55,7 +55,7 @@ function getTemplatesRedirect(store: Store) { const router = new Router({ mode: 'history', - base: window.BASE_PATH === '/{{BASE_PATH}}/' ? '/' : window.BASE_PATH, + base: import.meta.env.DEV ? '/' : window.BASE_PATH ?? '/', scrollBehavior(to, from, savedPosition) { // saved position == null means the page is NOT visited from history (back button) if (savedPosition === null && to.name === VIEWS.TEMPLATES && to.meta) { From 11551634d81e07049ede9719794e643d36294d4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 14 Oct 2022 09:35:16 +0200 Subject: [PATCH 3/4] fix the static urls on windows --- packages/cli/src/Server.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index eb5da9492c86e..825948eadb2f9 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -34,6 +34,7 @@ import { existsSync, readFileSync } from 'fs'; import { access as fsAccess, readFile, writeFile, mkdir } from 'fs/promises'; import os from 'os'; import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path'; +import { join as posixJoin } from 'path/posix'; import { createHmac } from 'crypto'; import { promisify } from 'util'; import cookieParser from 'cookie-parser'; @@ -1800,7 +1801,7 @@ class App { const srcFile = await readFile(filePath, 'utf8'); let payload = srcFile .replace(basePathRegEx, n8nPath) - .replace(/\/static\//g, pathJoin(n8nPath, 'static/')); + .replace(/\/static\//g, posixJoin(n8nPath, 'static/')); if (filePath.endsWith('index.html')) { payload = payload.replace(closingTitleTag, closingTitleTag + scriptsString); } From 6016cad4ac08c41b931670f245605c66ef5c028c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Fri, 14 Oct 2022 09:46:49 +0200 Subject: [PATCH 4/4] ffs node 14 --- packages/cli/src/Server.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 825948eadb2f9..7b561f86eee6f 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -34,7 +34,6 @@ import { existsSync, readFileSync } from 'fs'; import { access as fsAccess, readFile, writeFile, mkdir } from 'fs/promises'; import os from 'os'; import { dirname as pathDirname, join as pathJoin, resolve as pathResolve } from 'path'; -import { join as posixJoin } from 'path/posix'; import { createHmac } from 'crypto'; import { promisify } from 'util'; import cookieParser from 'cookie-parser'; @@ -1801,7 +1800,7 @@ class App { const srcFile = await readFile(filePath, 'utf8'); let payload = srcFile .replace(basePathRegEx, n8nPath) - .replace(/\/static\//g, posixJoin(n8nPath, 'static/')); + .replace(/\/static\//g, n8nPath + 'static/'); if (filePath.endsWith('index.html')) { payload = payload.replace(closingTitleTag, closingTitleTag + scriptsString); }