Skip to content

Instantly share code, notes, and snippets.

@conanak99

conanak99/image.js

Created Aug 20, 2017
Embed
What would you like to do?
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