From 96db501a615ff7ec91bb66ea49532a2c6ca2a172 Mon Sep 17 00:00:00 2001 From: oleg Date: Mon, 9 Sep 2024 17:33:52 +0200 Subject: [PATCH] fix(Chat Trigger Node): Fix auth in "Embedded Chat" mode (#10734) --- .../trigger/ChatTrigger/ChatTrigger.node.ts | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/ChatTrigger.node.ts b/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/ChatTrigger.node.ts index 57940b8c9..5c53a6900 100644 --- a/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/ChatTrigger.node.ts +++ b/packages/@n8n/nodes-langchain/nodes/trigger/ChatTrigger/ChatTrigger.node.ts @@ -460,20 +460,19 @@ export class ChatTrigger extends Node { const mode = ctx.getMode() === 'manual' ? 'test' : 'production'; const bodyData = ctx.getBodyData() ?? {}; - if (nodeMode === 'hostedChat') { - try { - await validateAuth(ctx); - } catch (error) { - if (error) { - res.writeHead((error as IDataObject).responseCode as number, { - 'www-authenticate': 'Basic realm="Webhook"', - }); - res.end((error as IDataObject).message as string); - return { noWebhookResponse: true }; - } - throw error; + try { + await validateAuth(ctx); + } catch (error) { + if (error) { + res.writeHead((error as IDataObject).responseCode as number, { + 'www-authenticate': 'Basic realm="Webhook"', + }); + res.end((error as IDataObject).message as string); + return { noWebhookResponse: true }; } - + throw error; + } + if (nodeMode === 'hostedChat') { // Show the chat on GET request if (webhookName === 'setup') { const webhookUrlRaw = ctx.getNodeWebhookUrl('default') as string;