【发布时间】:2020-02-24 01:43:48
【问题描述】:
我正在学习如何将一个简单的后端 node.js 项目部署到生产环境,在我的例子中是 heroku。我在 .env 文件中看到了有关环境变量的注释:
The environment variables defined in dotenv will only be used when the backend is not in production mode, i.e. Heroku.
We defined the environment variables for development in file .env, but the environment variable that defines the database URL in production should be set to Heroku with the heroku config:set command:
heroku config:set MONGODB_URI=mongodb+srv:...
如果使用 heroku 意味着我的后端处于生产模式,我的 .env 文件如何使用 heroku config:set MONGODB_URI=mongodb+srv... 环境变量?第一句话说明环境变量只用于开发模式。
我理解错了什么?开发模式和生产模式都使用了环境变量,我看的注释的措辞有误吗?
【问题讨论】:
标签: node.js heroku environment-variables development-environment production-environment