简体   繁体   English

表示从隐藏(点)文件夹中提供静态文件

[英]Does express serve static files from hidden (dot) folder

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 本地主机:8080 /静态/ .hidden /一些-的text.txt

I found this question from googling after I couldn't serve hidden files . 在我无法提供隐藏文件后,我从谷歌搜索发现了这个问题。 I discovered that express doesn't serve them by default. 我发现express默认不提供它们。

You can serve them with the dotfiles option: 您可以使用dotfiles选项为它们提供服务:

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). Nodemon没有发现我添加了一个.folder而没有重启服务器(我没注意到)。 When I restarted it manually everything worked like expected 当我重新启动它时,一切都按预期工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM