将Strapi推到Heroku不是生成.ENV文件,无法连接到Postgres
我一直在遵循Strapi网站上的教程: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/heroku.html.html.html#heroku.html#heroku-install-requirentess
但是,我要进行创建Postgres配置的步骤5,这一切都很奇怪。具体来说:
heroku config:set MY_HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)
heroku config:set APP_KEYS=$(cat .env | grep APP_KEYS | cut -d= -f2-)
heroku config:set API_TOKEN_SALT=$(cat .env | grep API_TOKEN_SALT | cut -d= -f2)
heroku config:set ADMIN_JWT_SECRET=$(cat .env | grep ADMIN_JWT_SECRET | cut -d= -f2)
heroku config:set JWT_SECRET=$(cat .env | grep -w JWT_SECRET | cut -d= -f2)
我不明白,当我什至没有.env文件时,这些命令应该如何设置变量。
如何从database_url
中生成.ENV文件?文档说,我们需要包括jwt_secret
,app_keys
和salt
之类的变量。我在哪里可以从哪里获得这些?
该部分应该解析database_url
并生成环境变量?
const config = parse(process.env.DATABASE_URL);
还是我在这里感到困惑?
该项目正在成功地建立和推动到Heroku,但是运行Heroku Open
不起作用。
另外,我碰巧意外地将其用于一个新的Strapi项目。 .ENV自行生成,并且Strapi服务器启动在Heroku上。但是现在,如果我删除.env,它甚至不会再次生成。
这是如此令人沮丧,我不知道如何使其在我的实际项目中起作用,而不是一个新项目。
I've been following the tutorial on strapi's website: https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment/hosting-guides/heroku.html#heroku-install-requirements
however, I get to step 5 of creating the postgres config, and it all gets weird. Specifically:
heroku config:set MY_HEROKU_URL=$(heroku info -s | grep web_url | cut -d= -f2)
heroku config:set APP_KEYS=$(cat .env | grep APP_KEYS | cut -d= -f2-)
heroku config:set API_TOKEN_SALT=$(cat .env | grep API_TOKEN_SALT | cut -d= -f2)
heroku config:set ADMIN_JWT_SECRET=$(cat .env | grep ADMIN_JWT_SECRET | cut -d= -f2)
heroku config:set JWT_SECRET=$(cat .env | grep -w JWT_SECRET | cut -d= -f2)
I don't understand, how are these commands supposed to set the variables when I don't even have the .env file.
How can I generate a .env file from the DATABASE_URL
? The docs say that we need to include the variables such as JWT_SECRET
, APP_KEYS
, and SALT
. Where can i get these from?
This part is supposed to parse the DATABASE_URL
and generate the environment variables?
const config = parse(process.env.DATABASE_URL);
Or am i confused over here?
The project is building and pushing to heroku successfully, however running heroku open
does not work.
Also, I happened to accidentally get it to work once on an new strapi project. The .env got generated on its own and the strapi server started on heroku. But now, if i delete the .env, it doesn't even generate again.
This is so frustrating, I don't know how to make it work on my actual project and not a new one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以随机制作新键,并将它们添加到Heroku Config变量中。您可以使用以下内容,而不是使用文档的部分:
这应该为您生成新密钥。然后将
my_heroku_url
添加到它们。You can make new keys randomly and add them to heroku config variables. Instead of using the part of the documentation you are using you can use this:
This should generate new keys for you. Then add
MY_HEROKU_URL
to them.