diff --git a/app/templates/crumbforest/role_chat.html b/app/templates/crumbforest/role_chat.html index 7454b5a..e54401d 100644 --- a/app/templates/crumbforest/role_chat.html +++ b/app/templates/crumbforest/role_chat.html @@ -97,16 +97,27 @@ body: formData }); - const data = await response.json(); - - // Remove loading - const loadingEl = document.getElementById(loadingId); - if (loadingEl) loadingEl.remove(); - if (response.ok) { + const data = await response.json(); + // Remove loading + const loadingEl = document.getElementById(loadingId); + if (loadingEl) loadingEl.remove(); + addMessage('assistant', data.answer); } else { - addMessage('error', data.answer || 'Error communicating with server.'); + // Try to parse error JSON, but handle HTML error pages (like 504) + let errorMsg = "Error communicating with server."; + try { + const data = await response.json(); + if (data.detail) errorMsg = data.detail; + else if (data.answer) errorMsg = data.answer; + } catch (e) { + errorMsg = `Server Error: ${response.status} ${response.statusText}`; + } + + const loadingEl = document.getElementById(loadingId); + if (loadingEl) loadingEl.remove(); + addMessage('error', errorMsg); } } catch (error) { diff --git a/native_crumbcore_v1/nginx/crumbforest-locations.conf b/native_crumbcore_v1/nginx/crumbforest-locations.conf index 7f0d114..77fc73a 100644 --- a/native_crumbcore_v1/nginx/crumbforest-locations.conf +++ b/native_crumbcore_v1/nginx/crumbforest-locations.conf @@ -15,7 +15,7 @@ location / { # Timeouts proxy_connect_timeout 60s; proxy_send_timeout 60s; - proxy_read_timeout 60s; + proxy_read_timeout 300s; # Buffering proxy_buffering on;