Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created August 20, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save conanak99/d648c814ec92439b57304d75c3015682 to your computer and use it in GitHub Desktop.
Save conanak99/d648c814ec92439b57304d75c3015682 to your computer and use it in GitHub Desktop.
app.get('/tracking.jpg', function(request, response) {
// Lấy id từ cookie và ghi log như bình thường
const userId = request.cookies.id;
const referrer = (request.header('Referer') || 'Empty').replace(/\/$/, "");;
const time = new Date();
const log = { userId, referrer, time };
db.log.insert(log, (err, result) => {
// Trả ra file ảnh "vô hại"
response.sendFile(__dirname + '/public/track.jpg');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment