fix: Decode HTML entities in chat responses and improve n8n error handling
Some checks failed
Dev Deployment (Zero Downtime) / deploy-dev (push) Has been cancelled

- Add HTML entity decoding for chat responses (fixes ' display issue)
- Add timeout handling for n8n webhook requests (30s chat, 10s status)
- Improve error logging with detailed error information
- Add N8N_SECRET_TOKEN support for authentication
- Better fallback handling when n8n is unavailable
- Fix server-side HTML entity decoding for chat and status endpoints
This commit is contained in:
2026-01-09 14:52:06 +01:00
parent 271703556d
commit 4184e2fcf0
4 changed files with 173 additions and 54 deletions

View File

@@ -125,9 +125,19 @@ export default function ChatWidget() {
const data = await response.json();
// Decode HTML entities in the reply
let replyText = data.reply || "Sorry, I couldn't process that. Please try again.";
// Decode HTML entities client-side as well (double safety)
if (typeof window !== 'undefined') {
const textarea = document.createElement('textarea');
textarea.innerHTML = replyText;
replyText = textarea.value;
}
const botMessage: Message = {
id: (Date.now() + 1).toString(),
text: data.reply || "Sorry, I couldn't process that. Please try again.",
text: replyText,
sender: "bot",
timestamp: new Date(),
};