Tell us what’s happening:
Test 2 of Lesson 4 always fails, and my attempts to output the server URL aren’t being detected properly. Hardcoding the desired output in the app.listen callback doesn’t work. Neither does using a middleware for it.
Your code so far
import express from 'express';
const app = express();
app.use('/', (req, res, next) => {
console.log('from middleware');
console.log(req.hostname);
next();
})
const server = app.listen(3000, ()=>{
const hostname = server.address().address;
console.log('listening callback');
console.log(hostname);
if(["::", "0.0.0.0"].includes(hostname)){
console.log("localhost");
}
})