When attempting to send a static page with just one '/' in the path, everything works smoothly. For instance:
app.get('/', (req, res) => {
res.render('home.ejs')
})
The necessary CSS linked to the HTML page via the <link>
attribute is rendered perfectly:
<link rel="stylesheet" href="style.css">
All HTML and CSS files are located in the same directory while the server.js file is in the preceding directory: https://i.sstatic.net/Kupxr.png
The server file is connected to the views
directory through:
app.use(express.static(__dirname + '/views'));
app.set('views', path.join(__dirname, 'views'));
However, upon adding an additional '/' in the path, the CSS fails to render:
app.get('/projects/mcpaint', (req, res) => {
res.render('mcpaint.ejs')
})
I tried embedding the CSS in the HTML using the <style>
tag which surprisingly resulted in successful rendering of the CSS.
If anyone has suggestions on how to rectify this issue, I would greatly appreciate it! Thanks for any assistance!