title: Unable to get client IP address in Express even after setting 'trust proxy' to true
body: <p>How do I retrieve the browser's IP address in a NextJS app? Right now, my custom <a href="https://github.com/amitschandillia/proost/blob/master/web/server/server.js" rel="nofollow noreferrer">server</a> has the following entries:</p>
  
  <pre><code>const server = express();
  server.set('trust proxy', true);
  </code></pre>
  
  <p>Then in my <a href="https://github.com/amitschandillia/proost/blob/master/web/pages/_app.jsx" rel="nofollow noreferrer">_app.js</a>:</p>
  
  <pre><code>const ip = ctx.req.header('x-forwarded-for') || ctx.req.connection.remoteAddress;
        console.log('IP ADDRESS', ip);
  </code></pre>
  
  <p>This whole thing is running behind an <a href="https://github.com/amitschandillia/proost/blob/master/.documentation/configs/default.conf" rel="nofollow noreferrer">NGINX proxy</a> which has the following directives:</p>
  
  <pre><code>proxy_redirect off;
  proxy_set_header Host $host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto $scheme;
  </code></pre>
  
  <p>Is there anything else that I'm missing out on? Because despite all this, I keep getting the localhost IP (127.0.0.1) in the console!</p>
  
  <p><strong>UPDATE</strong>: I tried <code>console.log('IP', ctx.req.ip);</code> and even that returned the same IP: <code>::ffff:127.0.0.1</code>.</p>