refactor(core): Move all base URLs to UrlService (no-changelog) (#8141)
This change kept coming up in #6713, #7773, and #8135. So this PR moves the existing code without actually changing anything, to help get rid of some of the circular dependencies. ## Review / Merge checklist - [x] PR title and summary are descriptive.
This commit is contained in:
committed by
GitHub
parent
517b050d0a
commit
baee47a276
@@ -12,18 +12,16 @@ import type {
|
||||
} from 'n8n-workflow';
|
||||
import { InstanceSettings } from 'n8n-core';
|
||||
|
||||
import config from '@/config';
|
||||
import { LICENSE_FEATURES } from '@/constants';
|
||||
import { CredentialsOverwrites } from '@/CredentialsOverwrites';
|
||||
import { CredentialTypes } from '@/CredentialTypes';
|
||||
import { LoadNodesAndCredentials } from '@/LoadNodesAndCredentials';
|
||||
import { License } from '@/License';
|
||||
import { getInstanceBaseUrl } from '@/UserManagement/UserManagementHelper';
|
||||
import * as WebhookHelpers from '@/WebhookHelpers';
|
||||
import config from '@/config';
|
||||
import { getCurrentAuthenticationMethod } from '@/sso/ssoHelpers';
|
||||
import { getLdapLoginLabel } from '@/Ldap/helpers';
|
||||
import { getSamlLoginLabel } from '@/sso/saml/samlHelpers';
|
||||
import { getVariablesLimit } from '@/environments/variables/enviromentHelpers';
|
||||
import { getVariablesLimit } from '@/environments/variables/environmentHelpers';
|
||||
import {
|
||||
getWorkflowHistoryLicensePruneTime,
|
||||
getWorkflowHistoryPruneTime,
|
||||
@@ -31,6 +29,7 @@ import {
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
import type { CommunityPackagesService } from '@/services/communityPackages.service';
|
||||
import { Logger } from '@/Logger';
|
||||
import { UrlService } from './url.service';
|
||||
|
||||
@Service()
|
||||
export class FrontendService {
|
||||
@@ -46,6 +45,7 @@ export class FrontendService {
|
||||
private readonly license: License,
|
||||
private readonly mailer: UserManagementMailer,
|
||||
private readonly instanceSettings: InstanceSettings,
|
||||
private readonly urlService: UrlService,
|
||||
) {
|
||||
loadNodesAndCredentials.addPostProcessor(async () => this.generateTypes());
|
||||
void this.generateTypes();
|
||||
@@ -61,7 +61,7 @@ export class FrontendService {
|
||||
}
|
||||
|
||||
private initSettings() {
|
||||
const instanceBaseUrl = getInstanceBaseUrl();
|
||||
const instanceBaseUrl = this.urlService.getInstanceBaseUrl();
|
||||
const restEndpoint = config.getEnv('endpoints.rest');
|
||||
|
||||
const telemetrySettings: ITelemetrySettings = {
|
||||
@@ -93,7 +93,7 @@ export class FrontendService {
|
||||
maxExecutionTimeout: config.getEnv('executions.maxTimeout'),
|
||||
workflowCallerPolicyDefaultOption: config.getEnv('workflows.callerPolicyDefaultOption'),
|
||||
timezone: config.getEnv('generic.timezone'),
|
||||
urlBaseWebhook: WebhookHelpers.getWebhookBaseUrl(),
|
||||
urlBaseWebhook: this.urlService.getWebhookBaseUrl(),
|
||||
urlBaseEditor: instanceBaseUrl,
|
||||
versionCli: '',
|
||||
releaseChannel: config.getEnv('generic.releaseChannel'),
|
||||
@@ -222,8 +222,8 @@ export class FrontendService {
|
||||
const restEndpoint = config.getEnv('endpoints.rest');
|
||||
|
||||
// Update all urls, in case `WEBHOOK_URL` was updated by `--tunnel`
|
||||
const instanceBaseUrl = getInstanceBaseUrl();
|
||||
this.settings.urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl();
|
||||
const instanceBaseUrl = this.urlService.getInstanceBaseUrl();
|
||||
this.settings.urlBaseWebhook = this.urlService.getWebhookBaseUrl();
|
||||
this.settings.urlBaseEditor = instanceBaseUrl;
|
||||
this.settings.oauthCallbackUrls = {
|
||||
oauth1: `${instanceBaseUrl}/${restEndpoint}/oauth1-credential/callback`,
|
||||
|
||||
Reference in New Issue
Block a user