Yeoman angular dist 版本的应用程序,不限制直接文件夹访问

Yeoman angular dist version of app, does not restrict the direct folder access

我的 angular 应用程序遇到了这个问题。

Dist版应用,不限制直接访问文件夹

所以 www.mysite.com/scripts 和 /images 和 /styles 文件夹可以访问。

这个问题不会在开发中出现,即 grunt serve 这是咕噜声 serve:dist.

我已经尝试使用 dist 文件夹的 .htaccess 来拒绝文件夹。但没有帮助

.htaccess 文件特定于 apache 服务器,但您是 运行 grunt,因此所有 .htaccess 文件都将被忽略。

您不应将 Grunt 用作生产服务器,因为它仅适用于本地开发环境。

看看这里: can grunt server use for production application deployment

可以将使用 grunt 生成的文件(在 dist 文件夹中)毫无问题地复制到任何其他服务器,旨在为生产中的文件(nginx 或 apache)提供服务。