From 97dbd958cc79d211cff16f05899cd1c32b8907a7 Mon Sep 17 00:00:00 2001 From: christiankrag Date: Mon, 15 Dec 2025 06:05:30 +0100 Subject: [PATCH] Fix chat endpoint - use text() instead of json() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - wws Response object may not have json() method - Parse response manually with JSON.parse 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- chat/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/chat/index.js b/chat/index.js index 8dd4a82..f05aab0 100644 --- a/chat/index.js +++ b/chat/index.js @@ -45,7 +45,14 @@ const handler = async (request) => { }) }) - const result = await n8nResponse.json() + // Use text() and parse manually (json() may not be available in wws) + const responseText = await n8nResponse.text() + let result + try { + result = JSON.parse(responseText) + } catch (e) { + result = { text: responseText } + } let response = new Response(JSON.stringify({ success: true,