Node.js w/ Matomo - Invalid IP Address

Greetings y’all!

I am attempting to get Matomo configured to work with Node.js. I visited this site and it was a little outdated.

Using the NPM and snippets from the link above, I was able to get a working version with this.

const MatomoTracker = require('matomo-tracker')
const matomo = new MatomoTracker(1, '')

// log matomo errors
matomo.on('error', function(error) {
       routeName: '',
       routeFunction: '',
       routeFunctionSub: '',
       userInput: '',
       message: error

app.set('trust proxy', 1)

// test
app.get('/test', async (req, res) => {
   // track url
       url: '',
       action_name: 'Test',
       ua: req.header('User-Agent'),
       language: req.header('Accept-Langauge'),
       // token_auth: process.env.MATOMO_TOKEN,
       // cip: req.ip

   res.status(200).json({IP: req.ip})

The problem is that the IP being captured is that of the server. I have seen other posts and the recommendation is that it is behind a proxy. I have several other WordPress domains using Matomo connecting to the same server with no issues. I created this /test to validate if I can pull my current IP address and I can.

I tried forcing the IP using cip and token_auth with no success, I receive an error 400. When I comment on the two lines I will capture the page view with the server IP.

I cannot locate additional information on how to use the cip to troubleshoot this error.

Node.js Project Dependencies:

 "dependencies": {
   "body-parser": "^1.20.2",
   "cors": "^2.8.5",
   "dotenv": "^16.0.3",
   "express": "^4.18.2",
   "hbs": "^4.2.0",
   "http": "^0.0.1-security",
   "joi": "^17.9.2",
   "matomo-tracker": "^2.2.4",
   "nodemon": "^2.0.22",
   "pg": "^8.11.0",
   "winston": "^3.9.0",
   "winston-daily-rotate-file": "^4.7.1"

Can anyone provide some direction for me in troubleshooting this?