Fix AI result panel visibility and nginx streaming headers.

ResultAI had h-0 collapsing output; add X-Accel-Buffering no, clearer fetch errors, and NGINX.md for gate proxy setup.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-10 22:56:22 +08:00
parent 38bbc7145a
commit 39181f21ad
7 changed files with 118 additions and 39 deletions
+14 -2
View File
@@ -10,6 +10,11 @@ import type { AiRequestBody } from "@/lib/ai/types";
export const runtime = "nodejs";
const STREAM_HEADERS = {
"Cache-Control": "no-cache, no-transform",
"X-Accel-Buffering": "no",
};
export async function POST(req: Request) {
try {
const body = (await req.json()) as AiRequestBody;
@@ -33,12 +38,19 @@ export async function POST(req: Request) {
maxRetries: 0,
});
return result.toTextStreamResponse();
const response = result.toTextStreamResponse();
for (const [key, value] of Object.entries(STREAM_HEADERS)) {
response.headers.set(key, value);
}
return response;
} catch (err) {
const message = err instanceof Error ? err.message : String(err);
return new Response(message, {
status: 500,
headers: { "Content-Type": "text/plain; charset=utf-8" },
headers: {
"Content-Type": "text/plain; charset=utf-8",
...STREAM_HEADERS,
},
});
}
}