Connect Cloud and IP addresses

Hello, I am interested in logging the IP address of visitors to my app (or really any other geographic information). I incorporated a function into my app that logs the user's IP address to a Google Sheet when they authenticate through the app. After some experimentation, it became clear that this was not working as I had hoped -- all traffic is basically seen as coming through the same private IP address (Posit's). Would a different approach, such as Google Analytics, yield the same issue? I suspect it would but I thought I would ask before repeatedly committing/pushing and republishing just to try different solutions.

P.S. I am using a "Basic" account if that impacts anything

Yeah, that's expected Posit (or RStudio Connect) acts as a proxy, so you’re just seeing its internal IP. Google Analytics might give you general geographic data, but not the actual IPs due to privacy rules. If you really need IPs, you'd probably need to log them from the client side using something like an external API (e.g., ipify) and send that back to your app manually.

Hi there,

The client's IP address should be exposed via X-Forwarded-For header that would be available to shiny or other application frameworks. However, that isn't currently working on Connect Cloud. We've opened an issue to correct that. I will make a note to update this thread once it's fixed.

Thanks @andy_kipp . My apologies for neglecting that in my initial post. I also tried X-Forward-For and it showed me three addresses each time: I believe two were internal/private Posit addresses and the third was similar to the local address you get when, for example, running a Shiny app locally in your browser.

I appreciate you looking into that issue. Thanks!