Reputation: 139
I want to be able to handle requests for any request for a .html file type. Is this possible?
Something like this:
// server.js
app.get('/*.html', (req, res) => {
// do something whenever a request is made for an html file
});
Upvotes: 0
Views: 749
Reputation: 1055
You can use regex to match the path that you want like so. You can find more about routing here https://expressjs.com/en/guide/routing.html.
app.get(/.*\.html$/, (req, res) => {
// do something whenever a request is made for an html file
});
Upvotes: 1