I want to load client side javascript chat.jsand css style.css in my html file but i get a 404 error while loading them.
This is my server file:
// routing
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
This is my client html:
<script src="/socket.io/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="chat.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
How can I load them in my app? All files are in the same root folder. I tried this but it doesn't work:
app.get('/', function (req, res) {
res.sendFile(__dirname + '/chat.js');
});