diff --git a/packages/cli/src/Interfaces.ts b/packages/cli/src/Interfaces.ts index bef98af6f9..b808a73564 100644 --- a/packages/cli/src/Interfaces.ts +++ b/packages/cli/src/Interfaces.ts @@ -288,6 +288,10 @@ export interface IN8nUISettings { saveManualExecutions: boolean; executionTimeout: number; maxExecutionTimeout: number; + oauthCallbackUrls: { + oauth1: string; + oauth2: string; + }; timezone: string; urlBaseWebhook: string; versionCli: string; diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index 67e3f8974b..c3e1780941 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -1617,7 +1617,9 @@ class App { // Returns the settings which are needed in the UI this.app.get(`/${this.restEndpoint}/settings`, ResponseHelper.send(async (req: express.Request, res: express.Response): Promise => { - return { + const urlBaseWebhook = WebhookHelpers.getWebhookBaseUrl(); + + const settings: IN8nUISettings = { endpointWebhook: this.endpointWebhook, endpointWebhookTest: this.endpointWebhookTest, saveDataErrorExecution: this.saveDataErrorExecution, @@ -1626,8 +1628,12 @@ class App { executionTimeout: this.executionTimeout, maxExecutionTimeout: this.maxExecutionTimeout, timezone: this.timezone, - urlBaseWebhook: WebhookHelpers.getWebhookBaseUrl(), + urlBaseWebhook, versionCli: this.versions!.cli, + oauthCallbackUrls: { + 'oauth1': urlBaseWebhook + `${this.restEndpoint}/oauth1-credential/callback`, + 'oauth2': urlBaseWebhook + `${this.restEndpoint}/oauth2-credential/callback`, + } }; })); diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 2f3973b848..bdb3fe0fa5 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -399,6 +399,10 @@ export interface IN8nUISettings { timezone: string; executionTimeout: number; maxExecutionTimeout: number; + oauthCallbackUrls: { + oauth1: string; + oauth2: string; + }; urlBaseWebhook: string; versionCli: string; } diff --git a/packages/editor-ui/src/components/CredentialsInput.vue b/packages/editor-ui/src/components/CredentialsInput.vue index 385f0ff9b5..ae678cb257 100644 --- a/packages/editor-ui/src/components/CredentialsInput.vue +++ b/packages/editor-ui/src/components/CredentialsInput.vue @@ -235,7 +235,7 @@ export default mixins( oAuthCallbackUrl (): string { const types = this.parentTypes(this.credentialTypeData.name); const oauthType = (this.credentialTypeData.name === 'oAuth2Api' || types.includes('oAuth2Api')) ? 'oauth2' : 'oauth1'; - return this.$store.getters.getWebhookBaseUrl + `rest/${oauthType}-credential/callback`; + return this.$store.getters.oauthCallbackUrls[oauthType]; }, requiredPropertiesFilled (): boolean { for (const property of this.credentialProperties) { diff --git a/packages/editor-ui/src/store.ts b/packages/editor-ui/src/store.ts index 1b54f3c1ad..8aabbdee02 100644 --- a/packages/editor-ui/src/store.ts +++ b/packages/editor-ui/src/store.ts @@ -8,6 +8,7 @@ import { IConnection, IConnections, ICredentialType, + IDataObject, INodeConnections, INodeIssueData, INodeTypeDescription, @@ -55,6 +56,7 @@ export const store = new Vuex.Store({ executionTimeout: -1, maxExecutionTimeout: Number.MAX_SAFE_INTEGER, versionCli: '0.0.0', + oauthCallbackUrls: {}, workflowExecutionData: null as IExecutionResponse | null, lastSelectedNode: null as string | null, lastSelectedNodeOutputIndex: null as number | null, @@ -490,6 +492,9 @@ export const store = new Vuex.Store({ setVersionCli (state, version: string) { Vue.set(state, 'versionCli', version); }, + setOauthCallbackUrls(state, urls: IDataObject) { + Vue.set(state, 'oauthCallbackUrls', urls); + }, addNodeType (state, typeData: INodeTypeDescription) { if (!typeData.hasOwnProperty('name')) { @@ -609,6 +614,9 @@ export const store = new Vuex.Store({ versionCli: (state): string => { return state.versionCli; }, + oauthCallbackUrls: (state): object => { + return state.oauthCallbackUrls; + }, // Push Connection pushConnectionActive: (state): boolean => { diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 742e0ae70f..92daf07ae4 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -1873,6 +1873,7 @@ export default mixins( this.$store.commit('setExecutionTimeout', settings.executionTimeout); this.$store.commit('setMaxExecutionTimeout', settings.maxExecutionTimeout); this.$store.commit('setVersionCli', settings.versionCli); + this.$store.commit('setOauthCallbackUrls', settings.oauthCallbackUrls); }, async loadNodeTypes (): Promise { const nodeTypes = await this.restApi().getNodeTypes();