Regex Bug Found in course: Back End Development and APIs > Basic Node and Express

This is for the course section: Back End Development and APIs > Basic Node and Express > Implement a Root-Level Request Logger Middleware

I couldn’t get the test to pass: “Root level logger middleware should be active”. I tried several different methods to achieve the required string format. I tried several different ways to set the middleware at root for all requests (e.g. app.use(), app.get(), app.use([function-only]), app.use(“/*”, [function])). I knew I was meeting the requirements to pass and I finally found the bug in the course tests when I switched to the Google Chrome browser - it displayed this log:

After this I was able to grep through the code base to find the module that tests for the correct user submitted conditions. I found this RegEx in wrappers.js in the fcc-express-background module under node_modules.:

The front half of the RegEx is great, it’s the part on the end that is matching the IP. It’s only looking for IPv4-style addresses (e.g. 123.456.789.012). However, as you can see in my screenshot above, my local browser’s IPs are coming through as ::1. I modified the RegEx to allow for this IPv6 localhost IP, and the test passed straight away.

This is a fairly wide-spread issue:

I hope that helps. I thought about submitting a pull request for the course repo but I just don’t know enough to be able to do that at this point.

Feel free to email me with any questions.

Welcome there,

Thank you. This is a known issue: Support IPv6 in logger test or force IPv4 in boilerplate-express · Issue #49234 · freeCodeCamp/freeCodeCamp · GitHub

Ok good to know. Thank you for the quick reply.

I see now. I was looking for the issue on the course github repo itself, not on the greater FreeCodeCamp repo.

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