Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

permit the proxy connection so we can track IPs #10

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`);
});
Loading