I
I
ivandao2019-11-18 13:28:11
Express.js
ivandao, 2019-11-18 13:28:11

How to apply middleware to multiple addresses at once?

How to apply middleware to several addresses at once (in one line):

app.use('/path1/', function(req, res) {...})
app.use('/path2/', function(req, res) {...})


Meaning like this:
app.use(['/path1/', "/path2/"], function(req, res) {...})


The route is not suitable, because in addition to middleware, other and different logic is tied to these addresses.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question