compose.yaml overrode the image's own entrypoint to start "tsx watch" and "next dev" with CHOKIDAR_USEPOLLING and WATCHPACK_POLLING enabled. The built dist/ and .next from the image were never used, and the polling watchers kept both containers busy around the clock whether or not anyone used the application. Split the two use cases: compose.yaml now runs node dist/server/index.js and next start with no source mounts and no watchers, and the watching setup moves to compose.dev.yaml. next build writes the rewrite destinations from next.config.mjs into .next/routes-manifest.json, so next start cannot pick up API_INTERNAL_URL at runtime the way next dev does. Pass it as a build argument. Give the web container its own probe. The healthcheck hit "/", which redirects to "/projects", and fetch follows redirects, so every probe rendered two pages every five seconds. "/health" could not serve as the probe because next.config.mjs rewrites it to the API. Add "/web-health" as a route handler, exclude it from the proxy matcher, and relax both intervals to 30s. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
24 lines
758 B
TypeScript
24 lines
758 B
TypeScript
import { NextResponse } from "next/server";
|
|
import type { NextRequest } from "next/server";
|
|
import { createLogger } from "./shared/logging/logger";
|
|
|
|
const logger = createLogger("web:navigation");
|
|
|
|
export function proxy(request: NextRequest) {
|
|
// Probes hit "/web-health" and are excluded by the matcher below. The
|
|
// User-Agent guard stays as a fallback for anything else that polls
|
|
// without one, so real navigation isn't drowned out in the logs.
|
|
if (request.headers.get("user-agent")) {
|
|
logger.info("page request", {
|
|
method: request.method,
|
|
path: request.nextUrl.pathname,
|
|
});
|
|
}
|
|
return NextResponse.next();
|
|
}
|
|
|
|
export const config = {
|
|
matcher: [
|
|
"/((?!_next/static|_next/image|favicon.ico|api|web-health).*)",
|
|
],
|
|
};
|