node.js - How to block routing to a page in the public folder -
i'm trying design nodejs application, there confused about. in application, plan put of frontend material in folder /public , put line app.use(express.static(__dirname + '/public')); in app.js file. so in place, user able go thesite.com/gallery/stuff , work because gallery folder in /public . but if don't want user able visit area? how can intercept request , make sure logged in, example? there way make parts of public folder not public? you can put router right before it app.all('/gallery/*', function(req, res, next){ if(!req.user) next(new error('you shall not pass!')); else next(); }); app.use(express.static(__dirname + '/public'));