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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user