How to get my external IP address with node.js?

后端 未结 14 1508
情深已故
情深已故 2020-12-06 05:00

I\'m using node.js and I need to get my external IP address, provided by my ISP. Is there a way to achieve this without using a service like http://myexternalip.com/raw ?

14条回答
  •  攒了一身酷
    2020-12-06 05:36

    I was looking for a solution not relying to other's libraries/ resources, and found this as acceptable alternative:

    Just a GET request to external server ( under my control ), where I read req.headers['x-forwarded-for'] and serve it back to my client.

提交回复
热议问题