在Express中添加Tracing斜线到所有路线
我如何redirect/about
/about/
和我的所有其他后续路线在Express? 我听说这样做的最佳做法。
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
有可以使用的connect-slashes
中间件 – https://www.npmjs.com/package/connect-slashes