How to set a page within a folder to the URL localhost: port-number?

user12200628

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?

anees

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to scrape multiple pages with page number within URL

Laravel: URL::to('/') port number for localhost not included in db seed files

Port number is removed when clicking a url in localhost/server

How to set the default page of a folder to open when the user enters the folder URL?

How to rename multiple folders that have a set number of files within that folder using batch script?

Where is or where should be the folder following the port number in a url?

On localhost, how do I pick a free port number?

How to connect url with port number in java with Jsoup?

How to add page number to the URL

How to set the proxy port and URL in R for the blsAPI

How can I set up a remote port forward on port 80 to my localhost with the help of setcap?

Wget command error (Error parsing proxy URL http://localhost:4001 : Bad port number.)

Invalid URI: Invalid port specified in C# on specifying URL with port number in it like http://localhost:8080/jasperserver/rest

Custom port number for my API running in localhost

How to set the port number for the client in udp (client ,server) program in java?

How can remove the port number from live vue site url?

How to get the port number from the URL using jQuery?

How to remove the :port number from the end of an IIS URL?

How to get Base URL with port number in codeigniter 3.0.3

How to set privacy policy url for a fb app when working on localhost?

How to set custom url for loading images on page

WP url: localhost / page / variable

How can I view the manual page for "set" from within bash

How can I set the number of OpenMP threads from within the program?

How to set a display value for a number range within an array?

How to set custom domain in Nexus Repo without port in URL

Remove port number in image url?

Redirect to a port number depending on the URL

Setting a URL to go to Localhost folder on XAMPP server