node.js - Add trailling slashes to all routes in Express -


how can redirect /about /about/ , other subsequent routes in express? heard best practice so.

app.js

// enable strict routing app.set('strict routing', true);  app.route('/').get(function(req, res) {     res.render('index', {       title: 'welcome'     }); });  app.route('/about').get(function(req, res) {     res.render('about', {       title: 'about'     }); });  //etc 

there connect-slashes middleware can make use of - https://www.npmjs.com/package/connect-slashes


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -