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
Post a Comment