Reputation: 85
I have a bunch of pages in my static-content folder
index.html
about.html
dashboard.html
How do route all of these to their page without having .html in the url. I want to this in one method without having to do it like this:
app.route('/about').get(function(req, res) {
return res.sendFile(path.join(__dirname, 'static-content/about.html'));
});
app.route('/dashboard').get(function(req, res) {
return res.sendFile(path.join(__dirname, 'static-content/dashboard.html'));
});
www.mysite.com/about
www.mysite.com/dashboard
Upvotes: 0
Views: 258
Reputation: 10520
Well, according to express.static
available options, you can make this work with using extensions: ['html']
within the express.static
.
app.use(express.static(__dirname + '/public', {
extensions: ['html']
}));
Upvotes: 2