From 186e987a44b10aed73463b8f65ff70db509206cb Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Mon, 14 Mar 2022 12:44:17 +0100 Subject: [PATCH 1/2] Use webhook url as fallback when editor url is not defined --- .../cli/src/UserManagement/UserManagementHelper.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/UserManagement/UserManagementHelper.ts b/packages/cli/src/UserManagement/UserManagementHelper.ts index e46278f63dd05..0da6bab9b537d 100644 --- a/packages/cli/src/UserManagement/UserManagementHelper.ts +++ b/packages/cli/src/UserManagement/UserManagementHelper.ts @@ -10,6 +10,7 @@ import { MAX_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, User } from '../databases/ent import { Role } from '../databases/entities/Role'; import { AuthenticatedRequest } from '../requests'; import config = require('../../config'); +import { getWebhookBaseUrl } from '../WebhookHelpers'; export async function getWorkflowOwner(workflowId: string | number): Promise { const sharedWorkflow = await Db.collections.SharedWorkflow!.findOneOrFail({ @@ -55,9 +56,14 @@ export async function getInstanceOwner(): Promise { * Return the n8n instance base URL without trailing slash. */ export function getInstanceBaseUrl(): string { - const editorBaseUrl = config.get('editorBaseUrl'); - const baseUrl = editorBaseUrl ? editorBaseUrl + config.get('path') : GenericHelpers.getBaseUrl(); - return baseUrl.endsWith('/') ? baseUrl.slice(0, baseUrl.length - 1) : baseUrl; + let n8nBaseUrl = getWebhookBaseUrl(); + + const editorBaseUrl = config.get('editorBaseUrl'); // defaults to empty string + if (editorBaseUrl) { + n8nBaseUrl = editorBaseUrl + config.get('path'); + } + + return n8nBaseUrl.endsWith('/') ? n8nBaseUrl.slice(0, n8nBaseUrl.length - 1) : n8nBaseUrl; } export async function isInstanceOwnerSetup(): Promise { From 450508d22d6b82ece71831e4b577565e5123578d Mon Sep 17 00:00:00 2001 From: Omar Ajoue Date: Mon, 14 Mar 2022 13:33:40 +0100 Subject: [PATCH 2/2] Updating editor url to not append path --- packages/cli/config/index.ts | 2 +- packages/cli/src/UserManagement/UserManagementHelper.ts | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/cli/config/index.ts b/packages/cli/config/index.ts index b6810bf9f6591..1e5b25f93306d 100644 --- a/packages/cli/config/index.ts +++ b/packages/cli/config/index.ts @@ -415,7 +415,7 @@ const config = convict({ format: String, default: '', env: 'N8N_EDITOR_BASE_URL', - doc: 'Public URL where the editor is accessible; path will be concatenated to this base. Also used for emails sent from n8n.', + doc: 'Public URL where the editor is accessible. Also used for emails sent from n8n.', }, security: { diff --git a/packages/cli/src/UserManagement/UserManagementHelper.ts b/packages/cli/src/UserManagement/UserManagementHelper.ts index 0da6bab9b537d..332a0efb7713d 100644 --- a/packages/cli/src/UserManagement/UserManagementHelper.ts +++ b/packages/cli/src/UserManagement/UserManagementHelper.ts @@ -56,12 +56,7 @@ export async function getInstanceOwner(): Promise { * Return the n8n instance base URL without trailing slash. */ export function getInstanceBaseUrl(): string { - let n8nBaseUrl = getWebhookBaseUrl(); - - const editorBaseUrl = config.get('editorBaseUrl'); // defaults to empty string - if (editorBaseUrl) { - n8nBaseUrl = editorBaseUrl + config.get('path'); - } + const n8nBaseUrl = config.get('editorBaseUrl') || getWebhookBaseUrl(); return n8nBaseUrl.endsWith('/') ? n8nBaseUrl.slice(0, n8nBaseUrl.length - 1) : n8nBaseUrl; }