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

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).


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

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

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

app.get("/json", (req, res) => {
            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:

Your code passes for me. Do you see any error messages in the Node console or in the browser console when you submit the project url?

What url are you submitting for the challenge?

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

Screen recording of the issue - (single use URL)

Can you please post the actual url you are trying to submit for the challenge?

It only works while the software is running on my PC, so if you look at it do it as soon as you can -

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

The code passes just fine if you use 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

When you submit the test with the url you provided, do you see any errors showing in the browser console (not the Node console)?

If you post your full working code on GitHub, I can pull it down locally and test it.

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 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.