The order of mywebapp.use important. If you have the first mywebapp.use(auth.connect(basic)); , then it will be used for each request, but if you change the order, it will go through the statics and will be used only for what is after it.
Middleware functions are processed to be added.
So the following should do what you want.
// no auth for statics mywebapp.use('/js', express.static(__dirname + '/files/js')); mywebapp.use('/css', express.static(__dirname + '/files/css')); // auth reguired from here mywebapp.use(auth.connect(basic));
If you post mywebapp.use(auth.connect(basic)); above express.static, it will also regress for it.
// auth reguired from here mywebapp.use(auth.connect(basic)); // auth required for statics as well mywebapp.use('/js', express.static(__dirname + '/files/js')); mywebapp.use('/css', express.static(__dirname + '/files/css'));
Molda source share