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; }); };