I have been working on an application using Node.js, express.js, and ejs. I am utilizing the following code to incorporate ejs and load css:
app.engine('.html', require('ejs').__express);
app.set('views', __dirname + '/views');
app.set('view engine', 'html');
app.use(express.static(__dirname + '/views'));
This is the structure of my directories:
myapp
--Controller
----admin.js
--db
----db.js
--views
----admin
------user.html
------addUser.html
----css
------style.css
--app.js
To link html with css, I use this format:
<link href="../css/style.css" rel="stylesheet">
I have applied css successfully for my website. However, when I include parameters like:
app.get('/admin/users', admin.users);
app.get('/admin/add', admin.add);
The URLs are:
localhost:1080/admin/users
localhost:1080/admin/add
and my css works properly. But when I add a parameter:
app.get('/admin/users/add', admin.add);
The URL becomes:
localhost:1080/admin/users/add
and my css doesn't work.
If anyone knows how to fix this issue, please provide assistance.