最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Does express serve static files from hidden (dot) folder - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question asked Jun 30, 2016 at 13:29 RouzRouz 1,3674 gold badges18 silver badges38 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 19

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

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

发布评论

评论列表(0)

  1. 暂无评论