regex - Using RegExp in express routes -


i'm trying write middleware, (e.g make logs) each /api/* request.

i wrote follow middleware, it's not working /api/me

var app = require('express'); app.all(/\/api/, function(req, res, next) {     console.log('hello'); }); 

what's wrong?

make sure middleware called before /api/ routes defined, , call next(), otherwise request hang.

var app = require('express'); app.use('/api/', function(req, res, next) {     console.log('hello');     next(); }); 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -