node-static icon indicating copy to clipboard operation
node-static copied to clipboard

Hidden files/folders

Open brettz9 opened this issue 7 years ago • 4 comments

Is there any means, whether through a generic filter by file name, or by config specifically targeting hidden files/folders, that one may prevent/enable hidden files from being served? Thanks!

brettz9 avatar Jul 14 '18 02:07 brettz9

Let's say "sometimes" you don't want to serve something.

require('http').createServer(function (request, response) {
    request.addListener('end', function () {
        // Serve files! ... or not?
        if(request.url.includes('mom')) {
             nodeStatic.serveFile('/nothing-about-mom.html', 404, {}, request, response);
         }
         nodeStatic.serve(request, response);
    }).resume();
}).listen(8080);

vovchisko avatar Jul 16 '18 20:07 vovchisko

Yes, sure, thanks--I should have mentioned though that I was hoping for a CLI option...

brettz9 avatar Jul 16 '18 21:07 brettz9

@brettz9 at least I don't see anything here https://github.com/cloudhead/node-static/blob/master/bin/cli.js

vovchisko avatar Jul 17 '18 10:07 vovchisko

This would be particularly helpful for an easy means to set up production static servers on the root of one's repository without fear of exposing .git.

brettz9 avatar Nov 22 '18 09:11 brettz9