This works for /path and /path/foo on express 4, note the *
before ?
.
router.get('/path/:id*?', function(req, res, next) {
res.render('page', { title: req.params.id });
});
More Related Contents:
- How to get GET (query string) variables in Express.js on Node.js?
- How do I debug error ECONNRESET in Node.js?
- No ‘Access-Control-Allow-Origin’ – Node / Apache Port Issue
- req.body empty on posts
- bodyParser is deprecated express 4
- Can I use a file based database on Heroku?
- How to access the GET parameters after “?” in Express?
- ExpressJS How to structure an application?
- Express.js – app.listen vs server.listen
- Render a variable as HTML in EJS
- How to implement many to many association in sequelize
- How to use a variable as a field name in mongodb-native findOne()?
- How to implement a secure REST API with node.js
- TypeError: db.collection is not a function
- Stream from a mongodb cursor to Express response in node.js
- How to protect the password field in Mongoose/MongoDB so it won’t return in a query when I populate collections?
- How to get a callback on MongoDB collection.find()
- Using PassportJS, how does one pass additional form fields to the local authentication strategy?
- Express command not found
- node.js http.get hangs after 5 requests to remote site
- NodeJS/express: Cache and 304 status code
- socket.io and express 4 sessions
- Having a hard time trying to understand ‘next/next()’ in express.js
- Is it possible to set a base URL for NodeJS app?
- Any way to serve static html files from express without the extension?
- How to organise file structure of backend and frontend in MERN
- What is the proper way to check for existence of variable in an EJS template (using ExpressJS)?
- Express.js Routing error: Can’t set headers after they are sent
- body-parser – extended option (qs vs querystring)
- How to limit upload file size in express.js