It seems that you are using the wrong template for the route. Here is the corrected one:
app.get('/days-ago/:days\.:ext?', function(req, res) {
Therefore, to achieve your goal, I would create middleware that checks an empty parameter and sets it to the desired
Something like that:
var defaultParamMiddleware = function(req, res, next) { if (!req.params.ext) { req.params.ext = 'json'; } next(); }; app.get('/days-ago/:days\.:ext?', defaultParamMiddleware, function (req, res) { res.json(req.params); });
source share