Reputation: 681
I am trying to mount a particular directory in an app to root. The structure of my app is
/app
/server.js
/views
/statics
/index.html
/partials
/public
/javascript
/css
/images
I want the static to be served as root so I can access index.html at localhostL:4001/index.html instead of localhostL:4001/static/views/index/html
I have tried to use express.statics. However, it didn't work.
in server.js
app.use(express.static('public'));
app.use('/', express.static('views/statics'));
Upvotes: 1
Views: 756
Reputation: 65
Currently you are using relative path to serve static files instead of this you can use absolute path for serving files like this
app.use(express.statics(path.join(__dirname, 'views/statics'));
This will solve your problem.
Upvotes: 1
Reputation: 1896
it should be app.use('/', express.static('views/statics'));
check the working model here : https://repl.it/@VikashSingh1/SlategrayDeadRobot
Upvotes: 1