Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use webhook url as fallback when editor url is not defined #2986

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/src/UserManagement/UserManagementHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<User> {
const sharedWorkflow = await Db.collections.SharedWorkflow!.findOneOrFail({
Expand Down Expand Up @@ -55,9 +56,9 @@ export async function getInstanceOwner(): Promise<User> {
* 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;
const n8nBaseUrl = config.get('editorBaseUrl') || getWebhookBaseUrl();

return n8nBaseUrl.endsWith('/') ? n8nBaseUrl.slice(0, n8nBaseUrl.length - 1) : n8nBaseUrl;
}

export async function isInstanceOwnerSetup(): Promise<boolean> {
Expand Down