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

c - Calling a function within a loop -

vb.net - Unbound DataGridView add row with checkbox error -

How i fill combobox items in Radgridview manually using in vb.net -