Skip to content
Advertisement

Cannot GET routes other than “/” express

I’m trying to create a web app with the MVC pattern and express in node.js. This is my project structure: project structure image

app.js:

JavaScript

loginController.js:

JavaScript

The problem is that I can access the index page (“/”) but not the login page (“/login”) even when the code for both is almost identical.

Here’s the code of indexController.js:

JavaScript

I don’t really know what’s happening, I’m kinda new to express and MVC and couldn’t find anything online, please help 🙂

Advertisement

Answer

You have ‘login’ twice. The first one is enough in app.use('/login', loginController); Inside, you can remove the other

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement