I’m working on a basic blog in Express.js. Say I have route structure like this:
/blog/page/:page
I would also like a /blog route that is essentially an alias for /blog/page/1. How can I handle this easily in Express?
All routes are defined like such:
app.get('/path', function(req, res) {
//logic
});
Use
res.redirectto tell the browser to redirect to/blog/page/1:Use a shared route handler and default to page 1 if the
pageparam is not passed: