From acc580fb798c94fa4ea08a9f26440f1c75c87d1d Mon Sep 17 00:00:00 2001 From: Mike Smith <89040888+smiggiddy@users.noreply.github.com> Date: Wed, 1 Jan 2025 16:46:22 -0500 Subject: [PATCH] feat: add client ip tracking --- nodejs-mini-message-board/src/app.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nodejs-mini-message-board/src/app.js b/nodejs-mini-message-board/src/app.js index d59c884..6bd601e 100644 --- a/nodejs-mini-message-board/src/app.js +++ b/nodejs-mini-message-board/src/app.js @@ -17,7 +17,9 @@ app.use(express.urlencoded({ extended: true })); //Logging app.use((req, res, next) => { req.time = new Date(Date.now()).toISOString(); - console.log(req.time, req.method, req.hostname, req.path); + const clientIp = + req.header("http_cf_connecting_ip") || req.socket.remoteAddress; + console.log(req.time, req.method, req.hostname, req.path, clientIp); next(); });