Does express serve static files from hidden (dot) folder

拈花ヽ惹草 提交于 2021-01-02 06:43:44

问题


My app is serving a static folder like this

app.use('/static', serveStatic(__dirname + '/view/my/static/folder'));

How to configure server to serve a hidden folder? So if i have

/view/my/static/folder/.hidden/some-text.txt

I would like to see this on

localhost:8080/static/.hidden/some-text.txt


回答1:


I found this question from googling after I couldn't serve hidden files. I discovered that express doesn't serve them by default.

You can serve them with the dotfiles option:

app.use(express.static( __dirname+'/static', {dotfiles:'allow'} ));

source




回答2:


Looks like the issue happened due to my stupidity. Nodemon did not catch that i added a .folder and did not restart server (which I did not notice). When I restarted it manually everything worked like expected



来源:https://stackoverflow.com/questions/38124612/does-express-serve-static-files-from-hidden-dot-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!