How to make express serve static files from another upper directory? How to make express serve static files from another upper directory? express express

How to make express serve static files from another upper directory?


Actually solved my problem by using:

app.use(express.static(path.join(__dirname, '/../client/public')));


You can use path.join()

app.use(express.static(path.join(__dirname,'public')));


just do this, (as per your directory structure)

app.use(express.static(path.join(__dirname, 'src/client/public'))); // http://localhost:3000/hello.html

or

app.use('/static', express.static(path.join(__dirname, 'src/client/public')))// http://localhost:3000/static/hello.html