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:
parent
53a8b5ed55
commit
57b3b2c175
2 changed files with 8 additions and 1 deletions
|
|
@ -83,8 +83,9 @@ export async function GET(request) {
|
||||||
return new Response(stream, {
|
return new Response(stream, {
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "text/event-stream",
|
"Content-Type": "text/event-stream",
|
||||||
"Cache-Control": "no-cache",
|
"Cache-Control": "no-cache, no-transform",
|
||||||
"Connection": "keep-alive",
|
"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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue