I have two apps, one front end and one a REST API back-end. How do I get the IP address of the user accessing the back-end when the front-end client makes a request to the back-end?
I have tried this.request.ip
, but it shows the IP of my front-end site, not my actual IP address.
That would be in the HTTP incoming request object. I don't know what property in the object from the top of my head, but you'll find it in your route if you simply log the request: console.log(this.request)
. You can bypass Koa and get the raw Node request object with this.req
instead - but I'm sure the client IP is available in the Koa request as well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.