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,