Mark Spencer Mark Spencer - 5 months ago 23
Node.js Question

Static files are not served

I want to serve css file(s) from the 'css' folder...

I have this line of code so far :

app.use("/static", express.static(path.resolve(__dirname + "/../views/public/css")));


I put
/../
to go a path backwards.

and this is my folder hierarchy:

Folder hierarchy

I go to
/static/styles.css
- the server can not get this

Answer

As described in my comment, node looks for static directories based off the main JS file. Try it without the /../ and it should work.