I am using Router module to route all requests to a specific authorization endpoint.
var router = Router();
app.use(router);
router.route('/*')
.all([auth, function(req, res){
res.send("Authorized").end();
}])
This works if my request url looks like /myapp/cat. But does not work if it is /myapp/cat?eyecolor=brown.
Is there any specific regex format I need to use to get the router recognize ? character and such?
This might help you.
"There is a special routing method, app.all(), which is not derived from any HTTP method. It is used for loading middleware at a path for all request methods." So I'm not exactly sure about router.route(). http://expressjs.com/guide/routing.html
Second: look at examples of route paths based on regular expressions at the above page. /.*fly$/ accepts butterfly, dragonfly, but not flybird. I think your mistake might be the ' ' of you little regexp.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.