Hey everyone, I'm facing a strange issue where the CSS styling and JS code are not loading when I access the route http://localhost:5000/posts/edit/<%=idofblog%>. As a result, my webpage looks very unattractive, and I'm not sure what's causing this issue since all other routes are working fine.
All my CSS and JS folders are located inside the public folder.
app.use(express.static(path.join(__dirname,'public')));
This is my file structure: enter image description here
Within the _layout folder, I have a header.ejs file that contains links to CSS like this:
<link rel="stylesheet" type="text/css" href="../css/register.css">
Every route works perfectly, but when I visit the route http://localhost:5000/posts/edit/<%=idofblog%>, all CSS and JS code disappear, along with images. Within the posts.js route, I have the following:
router.get('/edit/:id',(req,res)=>{
res.render('edit');
}); And the href link in the ejs file is as follows:
<a href="edit/<%=post._id%>" class="btn btn-info btn-rounded">Edit</a>
The page loads with all the input fields and textarea, but without any styling. I'm unsure of what I am doing wrong.