首页 > 解决方案 > Set .htpasswd .htaccess for React build directory

问题描述

I am using apache to host the ReactProject

I put .htpasswd and .htaccess in ReactProject/build directory, it works.

However once I did npm run build again.

Both files were deleted.

How can I prevent this??

标签: reactjsbasic-authentication

解决方案


您可以将它们放在公共文件夹中!

文件被删除的原因是每当你 npm run build 时,公共文件夹移动到 build 文件夹。它只是意味着如果你执行 npm run build,build 文件夹是由 public 文件夹创建的。


推荐阅读