[Fixed] "Cannot Get /" Error when try to access /about route

Issue

I try to made another route for my ‘web-educational-only’ it works when the route is ‘/’ but when i try to linked in with ‘about’ page, it’s show ‘Cannot Get /about’

here’s the code for app.js:

const express = require('express');
const app = express();

app.set('views','./view');
app.use(express.static('assets'));

app.get('/', (req, res) => {
    res.render('index.ejs');
});
app.get('/about', (req, res) => {
    res.render('about.ejs'); 
});

app.listen(3000);

and here’s for about.ejs (the file is in view folder):

<!DOCTYPE html>
<html>
<head>
    <title>About</title>
    
    <script src="/send_url.js"></script>
    <link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<h1>It's About the Page</h1>
<p class="alert">made for educational only</p>
</body>
</html>

can you see what’s the problem there? thank you

Solution

if you make any change in any file of your project then restart your server every time
use nodemon package in your project so that after making any changes in file you won’t have to manually restart the server, nodemon will detect changes and restart your server every time you make any change

Leave a Reply

(*) Required, Your email will not be published