If I have an nodejs express application with folowing folder structure:
-src
- client
- public
- css
- js
- ...
- views
- server
- server.js
- How can I serve the static files in the public folder from the server.js file, since it is located
above
the index.js root location? - How should the:
app.use(express.static();
look like?
----UPDATE---
SOLVED this by using: app.use(express.static(path.join(__dirname, '/../client/public')));
path.resolve(__dirname, '../client/public/')
might also work . e.g. withres.sendFile
instead ofexpress.static
. – Alex Glukhovtsev