fix(streaming): 修正流式输出的端点URL和防缓冲header

前端:
- kieaiGeminiChatStream URL 从 /gemini/chat 改为 /gemini/chat/stream
  (后者声明了 produces=text/event-stream,nginx 不会缓冲)
- 请求 header 增加 Accept: text/event-stream

后端:
- KieAIController.geminiChatStream 补充防缓冲 header:
  X-Accel-Buffering: no + Cache-Control: no-cache
  (与 CozeController.chatStream 对齐,防止 nginx 缓冲 SSE)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
msh-agent
2026-04-11 15:51:32 +08:00
parent 19b6dc1d2b
commit 58ea76498f
2 changed files with 10 additions and 2 deletions

View File

@@ -457,12 +457,15 @@ function kieaiGeminiChatStream(data) {
}
const token = store.state && store.state.app && store.state.app.token
// 使用专用流式端点 /chat/stream声明了 produces=text/event-stream
// 而非 /chat + stream=true避免 nginx 缓冲 SSE 响应导致流式失效
_task = uni.request({
url: `${API_BASE_URL}/api/front/kieai/gemini/chat`,
url: `${API_BASE_URL}/api/front/kieai/gemini/chat/stream`,
method: 'POST',
data: { messages, stream: true },
header: {
'Content-Type': 'application/json',
'Accept': 'text/event-stream',
...(token ? { [TOKENNAME]: token } : {})
},
enableChunked: true,