Reputation: 93
How am I supposed to go back up 1 level to find a file?
I was trying code bellow but It's not working
app.get('/', (req, res) => {
res.sendFile(__dirname + '../client-side/public/index.html');
});
This is my folder structure
Trying to go public folder under client-side folder
Upvotes: 0
Views: 128
Reputation: 50850
You are using +
which essentially outputs this path:
'/[__dirname]../client-side/public/index.html'
Try using path
module:
const path = require("path")
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, '../client-side/public/index.html'));
});
You can read more about path.join()
in the documentation
Upvotes: 1