I currently access my login page typing in the following URL to my browser - 'http://localhost:3000/pages/login'. The login page file is within a folder called 'pages'. I want to be able to be directed to the login page when I enter the following URL - 'http://localhost:3000/'. I know this might be incredibly easy to some of you, but I am very new to this and I have became confused with the application I using.
Here is my code below
controller file
//renders the login.hbs page
router.get('/login', (req, res) => {
res.render('pages/login', {
layout: 'main.hbs'
});
});
I tried changing the following code in numerous ways but it ended up giving me an error in which the page could not be found or trying to locate pages/pages/login. I am guessing if its in a folder 'pages' then this cant be done?
remove the route from pages router and add it to the app.js or your main server file directly like below.
make sure to remove any other routes that are attached to /
route and also delete the index.html file from public folder.
app.get('/', (req, res) => {
res.render('pages/login', {
layout: 'main.hbs'
});
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments