Get client IP in my next.js app served as an Azure static web app

43 Views Asked by At

I am self-hosting umami as a static web app on azure, together with a PostgreSQL db. The app is a next.js app. I am using a azure front door as well. All works well right out of the box when deployed, only issue is that when it is logging client IP:s, it picks up the static web app IP, not the actual client browsing the website, so all visits to the tracked website say they are from same country. Umami has option to add an environment variable, where you define which header should be picked up from the request, i.e CLIENT_IP_HEADER. I have tried using X-Forwarded-For, which doesn't work at all, and X-Real-IP logs the static web app IP again. How do I get the IP of the client browsing my site?

1

There are 1 best solutions below

0
DRNR On

I am not experienced in deploying next.js as a static web app, but since you are using Azure Front door, you also have the option to use the X-Azure-ClientIP header. That should give you the client IP address.