Struggling to make my CSS links functional while working on localhost. Currently, when I view Index.html on my server, it displays as plain text without any styling. Even after trying the express middleware, the CSS files are still not being served, resulting in a 404 error. Here is the snippet of code causing the issue:
App.js:
app.set('view engine', 'html');
app.engine('html', hbs.__express);
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'Public')));
Index.html:
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<link rel="stylesheet" type="text/css" media="all" href="/styles.css">
<link rel="stylesheet" type="text/css" media="all" href="/switchery.min.css">
<script type="text/javascript" src="/switchery.min.js"></script>
</head>
//UPDATE//
Realized my mistake with path.join argument setup. Grateful for the input provided. The corrected code that resolved the issue is shown below:
app.use(express.static(path.join(__dirname + '/public')));