How to get the user IP address in Meteor server?

前端 未结 6 811
情书的邮戳
情书的邮戳 2020-11-30 03:03

I would like to get the user IP address in my meteor application, on the server side, so that I can log the IP address with a bunch of things (for example: non-registered us

6条回答
  •  暖寄归人
    2020-11-30 04:06

    This answer https://stackoverflow.com/a/22657421/2845061 already does a good job on showing how to get the client IP address.

    I just want to note that if your app is served behind proxy servers (usually happens), you will need to set the HTTP_FORWARDED_COUNT environment variable to the number of proxies you are using.

    Ref: https://docs.meteor.com/api/connections.html#Meteor-onConnection

提交回复
热议问题