Skip to content

Commit

Permalink
fix(Log): stringify data
Browse files Browse the repository at this point in the history
  • Loading branch information
KevOneRedOne committed Dec 6, 2023
1 parent 62a5041 commit 53fe97e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ app.use((req, res, next) => {
if (process.env.STACK === 'development') {
const currentTime = new Date().toISOString();
const clientIp = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
console.log(`[${currentTime}] - Requête reçue : ${req.method}, ${req.url}, ${req.params}, ${req.body} , | de IP: [${clientIp}] `);
console.log(`[${currentTime}] - Requête reçue : ${req.method}, ${req.url}, ${JSON.stringify(req.params)}, ${JSON.stringify(req.body)} , | de IP: [${clientIp}] `);

if (req.method === 'POST' || req.method === 'PUT') {
console.log('Corps de la requête :', req.body);
}

}
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content, Accept, Content-Type, Authorization');
Expand Down

0 comments on commit 53fe97e

Please sign in to comment.