I am using Express + Node JS with my site and I have been trying to handle users' requests of 'www.mysite.com/' or 'www.mysite.com' to redirect to 'www.mysite.com/dashboard'. Is this possible and if so how is it done?! I have the following in my routes file:
app.get('/',function(req,res) {
res.redirect('/dashboard');
});
But this does not work.
do you assign the route for / BEFORE the route to /dashboard ?
Like this
app.get('/',function(req,res) {
res.redirect('/dashboard');
});
app.get('/dashboard',function(req,res) {
res.render('dashboard');
});
remove slash yes dashboard route also has to be define
app.get('/',function(req,res) {
res.redirect('dashboard');
});