How to protect static folder in express with passport

Ran into same issue, this is what I ended up doing!

app.use doesn’t let you chain middlewares in that way. The various
app.VERB functions do, but app.use doesn’t. That’s for one middleware
at a time.

If you split the 2 middlewares out into separate calls, you should get
the results you want:

app.use('/admin', ensureAuthenticated);
app.use('/admin', express.static(path.join(__dirname, 'admin')));

Cannot use basic authentication while serving static files using express

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)