Basic Node and Express - "Implement a Root-Level Request Logger Middleware" checks only pass on Repl.it

Tell us what’s happening:

I can’t seem to get the test to pass. I have added the middleware function and it appears to work exactly as the lesson wants, and the connection between freecodecamp and my server works just fine, but it always fails the test. I’m running the test locally, using ngrok to forward. No files have been modified from origin other than myApp.js and package-lock.json (which only has whitespace differences).

require('dotenv').config()

let express = require('express');
let app = express();

app.use((req,res,next) => {
    console.log(`${req.method} ${req.path} - ${req.ip}`)
    next()
})

app.get("/", (req, res) => {
    res.sendFile(__dirname + "/views/index.html")
})

app.get("/json", (req, res) => {
    res.json({
        message:
            process.env.MESSAGE_STYLE==="uppercase" ?
            "HELLO JSON" : "Hello json"
    })
})

app.use("/public", express.static(__dirname + "/public"))

module.exports = app;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:103.0) Gecko/20100101 Firefox/103.0

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

Link to the challenge:

i’m submitting an Ngrok URL, and there are no errors reported; the test just fails.

Screen recording of the issue - https://file.io/kzIHjBvnlLTf (single use URL)

It only works while the software is running on my PC, so if you look at it do it as soon as you can - https://d5ac-2607-fb91-1506-76f2-2c53-9cae-6e04-ddc9.ngrok.io

“GET /_api/root-middleware-logger” returned {“passed”: false}

The code passes just fine if you use repl.it. The test will not pass when running locally. I don’t really get how OS differences could cause this in particular to happen, because all the logic here doesn’t touch the OS and stays within Node. In case it helps, I’m running Windows 11, 20H2 and Node.js v17.9.0

There are no browser errors other than warnings from frame.ts that Quirks Mode is active. (to fix that, change the writeToFrame function to include at the top of the written document. it’s not absolutely nessecary but worth pointing out)

Did you try it without ngrok? You do not need that.

I do not have the ability to port-forward on my internet connection, I need ngrok or a very similar tool to be able to run it locally without a VPS.

Did you try it?

You can submit from localhost without doing anything. It is not an unsolicited inbound connection to your server on localhost.

Sorry, I had to figure out all the local host stuff myself, I didn’t see a guide. I assumed the remote server freecodecamp.org ran on would have been making the requests. It still does not pass with “http://localhost:3000”.

Not sure why it isn’t passing for you. Your code is also passing for me.

Check the network tab in the browser when submitting. Maybe try in a different browser just to test it or in a private Chrome window with no extensions.

If you can pass it using Replit then just get the checkmark using that and move on. The only thing that counts toward the certificates is the final projects.


There is a news guide but it isn’t linked to on the challenge pages.

In a private Google Chrome window (not my primary browser), no extensions; still fails.
root-middleware-logger still returns {“passed”: false}, so obviously nothing changed.


There’s a ‘preflight’ thing that’s failing but I’m not sure that’s really related. (I can’t attach the image, only one is allowed per post, but it says root-middleware-logger | 404 | preflight | Preflight (⇅) | 0 B | 20ms. the (⇅) symbol describes itself with Select the request that triggered this preflight when hovered over.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.