Is there a way to serve in-house ads based on the current user's location?

That’s because it only returns the content of https://your-discourse.com/admin/users/{user_id}.json. It ignores the ip-info part, it’s not a valid endpoint here.

And yes, I didn’t think about that :person_facepalming: but yes, I think you probably need a Maxmind key in order to return the location.

So, to summarize:

  1. If you want to get a user’s IP, you need to make a GET request (with admin credentials) to https://your-discourse.com/admin/users/{user_id}.json. It will return the IP among other user info.

  2. If you want to locate the IP, you need a Maxmind key (to be added in app.yml), and make a GET request to this endpoint: https://your-discourse.com/admin/users/ip-info.json?ip={user_ip} .

There’s the API documentation: https://docs.discourse.org/
But all endpoints aren’t listed here. Discourse’s API is very easy to reverse engine, though: Reverse engineer the Discourse API. This is how I got the info here.