From a5e5f289c1c055a52baa50d75fd90c69fcc25558 Mon Sep 17 00:00:00 2001 From: Wenyan Date: Thu, 30 Oct 2025 14:51:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=A6=E7=BB=86=E7=9A=84?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=E8=AF=B7=E6=B1=82=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=8C=E4=BE=BF=E4=BA=8E=E6=8E=92=E6=9F=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加日志: 1. 请求URL和配置 2. 响应状态 3. 错误详情(包含响应body) 4. 捕获所有异常 帮助诊断: - API_URL配置是否正确 - 请求是否发送成功 - 响应状态码和内容 - 具体的错误信息 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/services/api.client.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/app/services/api.client.ts b/app/services/api.client.ts index 0642548..248a903 100644 --- a/app/services/api.client.ts +++ b/app/services/api.client.ts @@ -529,14 +529,24 @@ export const fetchConversations = async () => { // 不再传递user参数,服务端会从JWT自动提取 }); - return fetch(`${CHAT_CONFIG.API_URL}/conversations?${params}`, { + const url = `${CHAT_CONFIG.API_URL}/conversations?${params}`; + console.log('📋 [API Client] 获取会话列表:', { url, apiUrl: CHAT_CONFIG.API_URL }); + + return fetch(url, { method: 'GET', credentials: 'include', // 携带cookie }).then(res => { + console.log('📋 [API Client] 会话列表响应:', { status: res.status, ok: res.ok }); if (!res.ok) { - throw new Error(`Failed to fetch conversations: ${res.status}`); + return res.text().then(text => { + console.error('❌ [API Client] 获取会话列表失败:', { status: res.status, body: text }); + throw new Error(`Failed to fetch conversations: ${res.status} - ${text}`); + }); } return res.json(); + }).catch(err => { + console.error('❌ [API Client] 会话列表请求异常:', err); + throw err; }); }; @@ -604,14 +614,24 @@ export const fetchChatList = async (conversationId: string) => { * ``` */ export const fetchAppParams = async () => { - return fetch(`${CHAT_CONFIG.API_URL}/parameters`, { + const url = `${CHAT_CONFIG.API_URL}/parameters`; + console.log('⚙️ [API Client] 获取应用参数:', { url, apiUrl: CHAT_CONFIG.API_URL }); + + return fetch(url, { method: 'GET', credentials: 'include', // 携带cookie }).then(res => { + console.log('⚙️ [API Client] 应用参数响应:', { status: res.status, ok: res.ok }); if (!res.ok) { - throw new Error(`Failed to fetch app params: ${res.status}`); + return res.text().then(text => { + console.error('❌ [API Client] 获取应用参数失败:', { status: res.status, body: text }); + throw new Error(`Failed to fetch app params: ${res.status} - ${text}`); + }); } return res.json(); + }).catch(err => { + console.error('❌ [API Client] 应用参数请求异常:', err); + throw err; }); };