Skip to content

Commit

Permalink
Merge pull request #10 from PipeItToDevNull/9-x-forwarded-for-is-set-…
Browse files Browse the repository at this point in the history
…but-the-express-trust-proxy-is-false

permit the proxy connection so we can track IPs
  • Loading branch information
PipeItToDevNull authored Nov 4, 2024
2 parents 692a204 + aaee433 commit 42203a4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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();
});

Expand Down Expand Up @@ -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}`);
});

0 comments on commit 42203a4

Please sign in to comment.