From b745cad72c6fcad23894150bf7edad0b568787b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 31 Jul 2025 12:59:42 +0200 Subject: [PATCH] fix(editor): Account for subpath when serving `config.js` (#17832) Co-authored-by: autologie --- packages/cli/src/commands/start.ts | 1 - packages/cli/src/server.ts | 1 - packages/frontend/editor-ui/index.html | 5 +++-- packages/frontend/editor-ui/public/static/base-path.js | 1 + packages/frontend/editor-ui/vite.config.mts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 packages/frontend/editor-ui/public/static/base-path.js diff --git a/packages/cli/src/commands/start.ts b/packages/cli/src/commands/start.ts index 3b436377e0..8984a9a89e 100644 --- a/packages/cli/src/commands/start.ts +++ b/packages/cli/src/commands/start.ts @@ -147,7 +147,6 @@ export class Start extends BaseCommand> { replaceStream('/{{BASE_PATH}}/', n8nPath, { ignoreCase: false }), replaceStream('/%7B%7BBASE_PATH%7D%7D/', n8nPath, { ignoreCase: false }), replaceStream('/%257B%257BBASE_PATH%257D%257D/', n8nPath, { ignoreCase: false }), - replaceStream('/static/', n8nPath + 'static/', { ignoreCase: false }), ]; if (filePath.endsWith('index.html')) { streams.push( diff --git a/packages/cli/src/server.ts b/packages/cli/src/server.ts index 99b9d5db2d..6b8e13f42d 100644 --- a/packages/cli/src/server.ts +++ b/packages/cli/src/server.ts @@ -293,7 +293,6 @@ export class Server extends AbstractServer { release: `n8n@${N8N_VERSION}`, }); const frontendConfig = [ - `window.BASE_PATH = '${this.globalConfig.path}';`, `window.REST_ENDPOINT = '${this.globalConfig.endpoints.rest}';`, `window.sentry = ${frontendSentryConfig};`, ].join('\n'); diff --git a/packages/frontend/editor-ui/index.html b/packages/frontend/editor-ui/index.html index f67e2fdd22..b402e678ac 100644 --- a/packages/frontend/editor-ui/index.html +++ b/packages/frontend/editor-ui/index.html @@ -5,9 +5,10 @@ - %CONFIG_SCRIPT% - + + + n8n.io - Workflow Automation diff --git a/packages/frontend/editor-ui/public/static/base-path.js b/packages/frontend/editor-ui/public/static/base-path.js new file mode 100644 index 0000000000..88f4c51d8f --- /dev/null +++ b/packages/frontend/editor-ui/public/static/base-path.js @@ -0,0 +1 @@ +window.BASE_PATH = '/{{BASE_PATH}}/'; diff --git a/packages/frontend/editor-ui/vite.config.mts b/packages/frontend/editor-ui/vite.config.mts index c1b57fa3a8..0f1d22d86c 100644 --- a/packages/frontend/editor-ui/vite.config.mts +++ b/packages/frontend/editor-ui/vite.config.mts @@ -128,7 +128,7 @@ const plugins: UserConfig['plugins'] = [ transformIndexHtml: (html, ctx) => { const replacement = ctx.server ? '' // Skip when using Vite dev server - : ''; + : ''; return html.replace('%CONFIG_SCRIPT%', replacement); },