req.header("X-Forwarded-For") breaks chai tests

If I use a hard coded IP during testing, all my chai tests work. ipaddress = ""

but when I revert to the way it’s written in my code:

const ipInfo = req.header("X-Forwarded-For").split(","); 
const ipaddress = ipInfo[0];

All my chai tests fail with:

Uncaught AssertionError: expected 500 to equal 200
      at tests/2_functional-tests.js:30:18
      at Test.Request.callback (/rbd/pnpm-volume/99b8ef6e-2db9-4ee9-a5d1-45bdb6db4465/node_modules/
      at IncomingMessage.<anonymous> (/rbd/pnpm-volume/99b8ef6e-2db9-4ee9-a5d1-45bdb6db4465/node_modules/
      at endReadableNT (_stream_readable.js:1125:12)
      at process._tickCallback (internal/process/next_tick.js:63:19)

Can anyone give me an idea of where the issue might be?