You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm at the step where you implement the routes using express.router.
If I use "app.get("/"... " in app.js it works fine. But when I try app.use("/", require("./routes/index")) it fails with "GET / 404".
It can't read the route.
Is there is something I'm not doing right?
The text was updated successfully, but these errors were encountered:
Something was definitely not right in the way I built the app.
I ended up using WSL to create a new app from scratch using express-generator and the router finally works.
The only thing I thought was my mistake is that the "app" express object in app.js is not the same object as the "express" object in routes/index.js and that would explain why it not capable of finding a working route for "/".
Even though my declarations were made exactly the same way and in the same sequence Brad shows in his video, I ended up creating two different objects that aren't sharing the same express instance.
I have seen other people complining about similar issues and that recreating the app would solve it.
I tried several times, both on Windows and on Ubuntu WSL.
The one that worked for me was using express-generator in a Ubuntu WSL session
I'm at the step where you implement the routes using express.router.
If I use "app.get("/"... " in app.js it works fine. But when I try
app.use("/", require("./routes/index"))
it fails with "GET / 404".It can't read the route.
Is there is something I'm not doing right?
The text was updated successfully, but these errors were encountered: