Reputation: 249
My file structure is as follows:
src
|- client
|- js
|- test.js
|- index.html
|- server
|- server.js
What I want to serve is the whole client folder. So on/
I should render index.html and also serve the js folder when I hit the /
route i.e just localhost:3000
in this example
My server.js file is as follows:
var express = require('express');
var app = express();
var path = require('path');
app.use(express.static(path.resolve(__dirname + '/../client')));
app.listen(3000, () => {
console.log('listening on: ', 3000);
})
I end up rendering the index.html file correctly but I do not receive the rest of the files/folders in the client directory.
Upvotes: 0
Views: 355
Reputation: 249
I had my script tag as minimized i.e <script src="js/test.js />
. This does not allow for the rest of the folder to load. I changed it to <script src="js/test.js></script>
Upvotes: 1