fix(console-log): initialize capture at server boot + prevent SSE proxy buffering
Initialize initConsoleLogCapture() via Next.js instrumentation register() hook so logs are captured from startup in headless/Docker deployments, and add X-Accel-Buffering/Cache-Control headers to the SSE stream route to prevent reverse proxies from buffering the initial payload.
This commit is contained in:
@@ -83,8 +83,9 @@ export async function GET(request) {
|
||||
return new Response(stream, {
|
||||
headers: {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
"Connection": "keep-alive",
|
||||
"X-Accel-Buffering": "no",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
6
src/instrumentation.js
Normal file
6
src/instrumentation.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export async function register() {
|
||||
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||
const { initConsoleLogCapture } = await import("@/lib/consoleLogBuffer");
|
||||
initConsoleLogCapture();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user