javascript - Get IP address from request object in Meteor -


i want retrieve client's ip address before redirect client external url.

here 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 ip address request object?

according the iron-router guide, request this.request typical nodejs request object:

router.route('/download/:file', function () {   // nodejs request object   var request = this.request;    // nodejs  response object   var response = this.response;    this.response.end('file download content\n'); }, {where: 'server'}); 

so should able loop ip address in this.request.connection.remoteaddress.

as stated in this answer, may have in this.request.headers['x-forwarded-for'] in cases.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -