I am currently working on a Node.js/Express app and I'm facing an issue where my browser is unable to find my style.css file, even though I am using a static file.
Here is the directory structure:
public -> css -> styles.css
server -> server.js
views -> layout -> header.ejs
In header.ejs :
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/asset/css/style.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
In my server.js :
// Middleware
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(session({
secret: 'kfhkhkgfkgfkhgjdkdkk',
resave: false,
saveUninitialized: true,
cookie: { secure: false }
}));
app.use(require('./middlewares/flash'));
app.use('/asset', express.static(__dirname + '/public'));
Thank you in advance for your assistance ;)