Skip to content

Instantly share code, notes, and snippets.

@conanak99

conanak99/server.js

Created Aug 20, 2017
Embed
What would you like to do?
// Tracking API
app.get('/logWrite', function(request, response) {
// Lấy id người dùng thông qua cookie
const userId = request.cookies.id;
const referrer = request.header('Referer').replace(/\/$/, "");;
const time = new Date();
const log = {userId, referrer, time};
// Ghi log vào database
db.log.insert(log, (err, result) => {
response.header('Access-Control-Allow-Origin', referrer);
response.header('Access-Control-Allow-Credentials', 'true');
response.json(result);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment