.env 在我的 git 仓库中

.env in my git repo

我的 .env 存储在我的 git 存储库中,它被发布到 heroku 和 bitbucket。

我知道发布 .env github 不好,但是 由于 bitbucket 是私有的,而 heroku 是用于生产的,我的秘密 keys/values 是否处于危险之中?

您的 bitbucket 存储库是私有的,因此您存储在那里的任何内容只有您明确授权访问您的存储库的人才能看到,当然,除非 bitbucket 被黑...

无论如何,您都需要通过 "heroku config" 为 Heroku 配置环境变量,因此它们也在您的 git 存储库中这一事实并没有真正进一步损害它们。同样,只有具有明确访问权限的人才能看到您的 Heroku 配置变量或访问您的 Heroku git 存储库。

理论上,不会。但我不会依赖于将秘密存储到要复制的存储库中(即 git 存储库)

至少考虑一下“Configuration and Config Vars”:

The traditional approach for handling such config vars is to put them under source - in a properties file of some sort. This is an error-prone process, and is especially complicated for open source apps which often have to maintain separate (and private) branches with app-specific configurations.

A better solution is to use environment variables, and keep the keys out of the code. On a traditional host or working locally you can set environment vars in your bashrc file. On Heroku, you use config vars.

Use the Heroku CLI’s config, config:set, config:get and config:unset to manage your config vars