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:
+14
-2
@@ -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,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user