我知道堆栈溢出有相同/相似的问题,我也阅读了文档-我还是什么都不懂-如何设置这些变量并在哪里!设置它们.
I know there are the same/similar questions on stack overflow and I have read the documentation too-I just still don't understand ANYTHING- how to set those variables and WHERE!! to set them.
我的env/production.js文件:
My env/production.js file:
module.exports = { "DATABASE_URI": process.env.DATABASE_URI, "SESSION_SECRET": process.env.SESSION_SECRET, "TWITTER": { "consumerKey": process.env.TWITTER_CONSUMER_KEY, "consumerSecret": process.env.TWITTER_CONSUMER_SECRET, "callbackUrl": process.env.TWITTER_CALLBACK }, "FACEBOOK": { "clientID": process.env.FACEBOOK_APP_ID, "clientSecret": process.env.FACEBOOK_CLIENT_SECRET, "callbackURL": process.env.FACEBOOK_CALLBACK_URL }, "GOOGLE": { "clientID": process.env.GOOGLE_CLIENT_ID, "clientSecret": process.env.GOOGLE_CLIENT_SECRET, "callbackURL": process.env.GOOGLE_CALLBACK_URL }, "LOGGING": true };在我的env/development.js文件中,设置变量(链接到我的PostgreSQL/localhost/xxx).因为必须使用Heroku创建一个数据库,我是否需要在Heroku中为所有数据库(Google,Facebook等)设置它们,还是只为数据库设置它们?我是否将指向本地数据库的链接保留在开发文件中,并单独链接至Heroku数据库?
In my env/development.js file I set the variables (linked to my PostgreSQL/localhost/xxx). Do I need to set them in Heroku for all (Google, Facebook etc.) or just for the database, since I had to create one with Heroku? Do I leave the link to my local database in my development file and link to the Heroku database separately?
我什至不知道我是否应该从命令行执行此操作?在文档中说:Heroku config:get CONFIG-VAR-NAME -s>>.env所以是Heroku config:get我的HEROKU数据库的配置名称-s>>.env 吗?
I don't even know if I am supposed to do it from my command line?! In the documentation it says: Heroku config:get CONFIG-VAR-NAME -s >> .env so would it be Heroku config:get CONFIG-NAME OF MY HEROKU DATABASE -s >> .env ?
我是第一次部署,真是太困惑了!帮助:)
I'm deploying for the first time and so confused! Help :)
推荐答案根据文档您可以使用 heroku CLI
$ heroku config:set DATABASE_URI=database_uri_here $ heroku config:set SESSION_SECRET=session_secret ... and so on for each variable,,或者您可以使用UI dashboard-classic.heroku/apps/ {your-app-name}/settings并通过网络界面提供相同的变量,如我在上面的评论中所述
or you could use UI dashboard-classic.heroku/apps/{your-app-name}/settings and provide same variables via web interface, as I mention in above comment
NODE_ENV = production 未被 heroku 特殊对待,因此您需要提供它以及任何其他env变量
NODE_ENV=production is not treated specially by heroku, so you do need to provide it as well as any other env variable
ps:严格来说,这个问题并不真正属于SO,因为它与编程无关.也许需要将其移至 SU
更多推荐
如何在Heroku for Node应用程序上设置环境变量并连接到PostgreSQL数据库?
发布评论