Request Header Parser Microservice - Not Passing Tests - Solved!

I believe my project should be passing the tests, but it is not. I thought maybe it was Glitch so I created the project on Heroku as well. The output seems accurate, but maybe I am missing something obvious?

Here are the links:
https://fcc-apis-proj2.herokuapp.com/api/whoami
and
https://charm-halved-beast.glitch.me/api/whoami

Your code so far
app.get("/api/whoami", function (req, res) {
let ip = req.header(‘x-forwarded-for’) || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress;
if (ip.indexOf(’,’) > -1){
ip = ip.slice(0,ip.indexOf(’,’));
}
let lang = req.header(‘accept-language’);
let sysInfo = req.get(‘user-agent’);
res.json({
ipaddress: ip,
language: lang,
software: sysInfo
});
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Request Header Parser Microservice

Link to the challenge:

I solved this myself. It was obvious, but not a problem with my code. I was submitting the full URL with the api end point (including /api/whoami). I needed to remove that from the URL and just submit the root without the /api/whoami.

2 Likes