Basic Node and Express - Implement a Root-Level Request Logger Middleware

Code that is passing on Replit is also now failing for me locally.

Not sure what the issue is but newer Node.js versions seem to be causing issues with some of the tests. I had to change the localhost to use 0.0.0.0 in another challenge and in this challenge, if I go back to Node.js v16.18.0 it passes the logger test again (from v18).

Node.js v16.18.0 logs

GET /json - ::ffff:127.0.0.1

Node.js v18.12.1 logs

GET /json - ::1

Which is an IPv6 address

I think this is related to Node.js switching the IP order

Node.js now returns IP addresses in the order they are returned from the name resolver/DNS

https://github.com/nodejs/node/issues/40537
https://github.com/nodejs/node/pull/39987

You can set the dns in server.js which should fix it (does for me).

const dns = require('dns');
dns.setDefaultResultOrder('ipv4first');

https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder

Or using nvm/nvm-windows and switching to Node.js 16 should fix it as well (nvm is just a Node.js version manager).