I want to retrieve the client's IP address before I redirect the client to an external URL.
Here is my code:
Router.route('/:_id', {name: 'urlRedirect', where: 'server'}).get(function () {
var url = Urls.findOne(this.params._id);
if (url) {
var request = this.request;
var response = this.response;
var headers = request.headers;
console.log(headers['user-agent']);
this.response.writeHead(302, {
'Location': url.url
});
this.response.end();
} else {
this.redirect('/');
}
});
My question is: Can I get the IP address from the request
object?