[英]How to use .env file while deploying my app?
I want to deploy my app using Heroku but I have kept my API keys in.env file which will be ignored by.gitignore file while pushing to Heroku and after deploying my app on Heroku, it is no longer able to read my API keys and app crashes? I want to deploy my app using Heroku but I have kept my API keys in.env file which will be ignored by.gitignore file while pushing to Heroku and after deploying my app on Heroku, it is no longer able to read my API keys and应用程序崩溃? What to do in this case?在这种情况下该怎么办? How to use it correctly?如何正确使用?
If your not storing your.env file in your git repository (which is absolutely the correct thing to do) then you need to manually configure the.env file once you deploy it.如果您没有将 your.env 文件存储在 git 存储库中(这绝对是正确的做法),那么您需要在部署后手动配置 .env 文件。
In the instance of Heroku you can set Config Vars:在 Heroku 的实例中,您可以设置 Config Vars:
Configuration and Config Vars配置和配置变量
If you do it that way I believe you have to access the vars in a different manor to env values but it has a local mode so that shouldn't be a problem.如果你这样做,我相信你必须以不同的庄园访问 vars 到 env 值,但它有一个本地模式,所以这不应该是一个问题。
You have to specify all the API keys in your START script in "package.json".您必须在“package.json”中的 START 脚本中指定所有 API 键。 Like below如下所示
"start": "MONGO_USER=abcis app.js" “开始”:“MONGO_USER=abcis app.js”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.