From aaee4339028a14acec8dabcf7b248c4655b7547a Mon Sep 17 00:00:00 2001 From: PipeItToDevNull Date: Sun, 3 Nov 2024 20:47:16 -0500 Subject: [PATCH] permit the proxy connection so we can track IPs --- api/api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/api.js b/api/api.js index 7774595..e33cb3d 100755 --- a/api/api.js +++ b/api/api.js @@ -17,6 +17,7 @@ const __dirname = path.dirname(__filename); const app = express(); const port = process.env.PORT || 3000; +app.set('trust proxy', true); // Configure Winston logger const logger = winston.createLogger({ @@ -77,7 +78,7 @@ app.use(limiter); // Middleware to log incoming requests app.use((req, res, next) => { - logger.info(`Incoming request: ${req.method} ${req.url}`, { body: req.body }); + logger.info(`Incoming request: ${req.ip} ${req.method} ${req.url}`, { body: req.body }); next(); }); @@ -173,7 +174,7 @@ app.use((err, req, res, next) => { res.status(500).send('Something broke, I lost my 418'); }); -// Start the server +// Start the Express server app.listen(port, () => { logger.info(`App listening at http://localhost:${port}`); });