I am new at Node.js so i have problem and I couldn't figure it out. Problem is I can't see my css properties in my website when I try to send my index.html with node.js. I will share with my directory and also codes so may you can find what is wrong. I should tell that when I try to click right on my html then hit the click on open with live server I can see my CSS properly but when I try to call with node.js I can't see them.
HTTP Status for CSS file is 200 so everything is fine there but I still can't see my css
// I send my index.html as a Homepage here
app.use('/', (req, res, next) => {
res.sendFile(path.join(__dirname,'./','views','index.html'));
});
//Here my <link tag in index.html
<link rel="stylesheet" type="text/css" href="/dist/css/style.css"/>
And you can see my directory here
CodePudding user response:
You need to make the dist/
directory public so that browser can read files from them.
Try adding this line
app.use(express.static('dist'));
Recommended to put this before your routes start.