From 8476e1d838c4c90027685ecf90104d9ad78595e8 Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 22 May 2025 18:46:19 +0200 Subject: [PATCH] W n8n --- lib/services/n8n-service.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/services/n8n-service.ts b/lib/services/n8n-service.ts index 295e541a..fa307688 100644 --- a/lib/services/n8n-service.ts +++ b/lib/services/n8n-service.ts @@ -18,7 +18,16 @@ export class N8nService { async triggerMissionCreation(data: any): Promise { try { - console.log('Triggering n8n workflow with data:', JSON.stringify(data, null, 2)); + // Add API key to the data + const dataWithApiKey = { + ...data, + config: { + ...data.config, + N8N_API_KEY: this.apiKey + } + }; + + console.log('Triggering n8n workflow with data:', JSON.stringify(dataWithApiKey, null, 2)); console.log('Using webhook URL:', this.webhookUrl); console.log('API key present:', !!this.apiKey); @@ -30,7 +39,7 @@ export class N8nService { 'Content-Type': 'application/json', 'x-api-key': this.apiKey }, - body: data + body: dataWithApiKey }; console.log('Full request details:', JSON.stringify(requestDetails, null, 2)); @@ -40,7 +49,7 @@ export class N8nService { 'Content-Type': 'application/json', 'x-api-key': this.apiKey }, - body: JSON.stringify(data), + body: JSON.stringify(dataWithApiKey), }); console.log('Webhook response status:', response.status);