I have routes in separate folder for expressjs. The setup is working fine for the 'index' page, but not for any additional routes.
This is my index.js, inside my routes folder.
module.exports = function(db) {
return {
index: function(req, res, next) {
res.send('index');
}
}
}
This is my join.js, inside my routes folder.
module.exports = function(db) {
return {
join: function(req, res, next) {
res.send('join');
}
}
}
In my app.js, I define my routes like this:
var routes = require('./routes')(db);
app.get('/', routes.index);
app.get('/join', routes.join);
When I go to http://localhost:3000
but when I go to http://localhost:3000/join
i get Cannot GET /join
If I define my route for join like this:
app.get('/join', function(req, res){
res.send('join 2');
});
This works.
Any idea what I'm doing wrong here?
Thank you!