Exclude route from express middleware

前端 未结 8 1603
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 02:40

I have a node app sitting like a firewall/dispatcher in front of other micro services and it uses a middleware chain like below:

...
app.use app_lookup
app.u         


        
8条回答
  •  难免孤独
    2020-12-05 03:40

    You can also skip route like this by putting a condition on req.originalUrl:

    app.use(function (req, res, next) {
    
        if (req.originalUrl === '/api/login') {
        return next();
        } else {
             //DO SOMETHING
        }
    

提交回复
热议问题