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
Post a Comment