Created
August 20, 2017 15:17
-
-
Save conanak99/d648c814ec92439b57304d75c3015682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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