feat(F-139): completed feature
This commit is contained in:
@@ -19,13 +19,17 @@ export async function GET(req: NextRequest) {
|
||||
headers: { Cookie: cookies },
|
||||
});
|
||||
if (path === 'admin/logs/stream') {
|
||||
// Pipe SSE directly: Next.js App Router supports ReadableStream passthrough.
|
||||
// X-Accel-Buffering: no tells any intermediate proxy (nginx) not to buffer.
|
||||
const headers = new Headers();
|
||||
headers.set('Content-Type', backendRes.headers.get('content-type') ?? 'text/event-stream');
|
||||
headers.set('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
headers.set('X-Accel-Buffering', 'no');
|
||||
// Do NOT set Connection: keep-alive — it is HTTP/1.1 default for persistent
|
||||
// connections and can confuse proxies that do not expect streaming.
|
||||
return new Response(backendRes.body, {
|
||||
status: backendRes.status,
|
||||
headers: {
|
||||
'Content-Type': backendRes.headers.get('content-type') ?? 'text/event-stream',
|
||||
'Cache-Control': backendRes.headers.get('cache-control') ?? 'no-cache',
|
||||
Connection: 'keep-alive',
|
||||
},
|
||||
headers,
|
||||
});
|
||||
}
|
||||
const data = await backendRes.json().catch(() => null);
|
||||
|
||||
Reference in New Issue
Block a user