From 6a4537bd01e24617479b66d32da65d27c6f3bcfc Mon Sep 17 00:00:00 2001 From: Mike Kao Date: Tue, 2 Jan 2024 16:42:42 +0000 Subject: [PATCH] log middlware --- server/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/server/index.ts b/server/index.ts index e78d5a577..6c7a22b27 100644 --- a/server/index.ts +++ b/server/index.ts @@ -40,6 +40,17 @@ const dev = process.env.NODE_ENV !== 'production'; const app = next({ dev }); const handle = app.getRequestHandler(); +const logMiddleware = (req: Request, res: Response, next: NextFunction) => { + // Log information about the incoming request + console.log(`Request Method: ${req.method}`); + console.log(`Request URL: ${req.url}`); + console.log(`Request Headers: ${JSON.stringify(req.headers)}`); + console.log(`Request Body: ${JSON.stringify(req.body)}`); + + // Continue processing the request + next(); +}; + app .prepare() .then(async () => { @@ -95,6 +106,9 @@ app startJobs(); const server = express(); + + server.use(logMiddleware); + if (settings.main.trustProxy) { server.enable('trust proxy'); }