[英]i have an api key in the bin/secrets. How can heroku find it?
I just recently worked with an api and with security in mind, have it placed in the bin/rails secrets
file.我最近刚使用 api 并考虑到安全性,将其放在bin/rails secrets
文件中。 I have it listed below like我在下面列出了它
development:
google_api_key: abcd1234
production:
google_api_key: abcd1234
However when I push everything to heroku, I get application errors.但是,当我将所有内容推送到 heroku 时,出现应用程序错误。 When I look at the logs I see.当我查看日志时,我看到了。
2020-08-04T22:34:28.529917+00:00 app[web.1]: /app/config/environment.rb:5:in `<top (required)>'
2020-08-04T22:34:28.529918+00:00 app[web.1]: config.ru:3:in `require_relative'
2020-08-04T22:34:28.529918+00:00 app[web.1]: config.ru:3:in `block in <main>'
2020-08-04T22:34:29.113486+00:00 heroku[web.1]: Process exited with status 1
2020-08-04T22:34:29.152963+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-04T22:34:29.605524+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=downtown-inventory-app.herokuapp.com request_id=1a1f61ec-458d-46c7-ada0-38ff05280586 fwd="107.77.206.194" dyno= connect= service= status=503 bytes= protocol=https
2020-08-04T22:34:30.628910+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=downtown-inventory-app.herokuapp.com request_id=d65ed41c-368e-451b-b70f-480b160e4c45 fwd="107.77.206.194" dyno= connect= service= status=503 bytes= protocol=https
2020-08-04T22:37:15.442465+00:00 app[api]: Set RAILS_MASTER_KEY config vars by user email@gmail.com
2020-08-04T22:37:15.442465+00:00 app[api]: Release v77 created by user email@gmail.com
2020-08-04T22:37:15.616389+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-04T22:37:20.612387+00:00 heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb`
2020-08-04T22:37:22.765114+00:00 app[web.1]: Puma starting in single mode...
2020-08-04T22:37:22.765140+00:00 app[web.1]: * Version 3.12.6 (ruby 2.5.8-p224), codename: Llamas in Pajamas
2020-08-04T22:37:22.765143+00:00 app[web.1]: * Min threads: 5, max threads: 5
2020-08-04T22:37:22.765147+00:00 app[web.1]: * Environment: production
2020-08-04T22:37:26.041214+00:00 app[web.1]: ! Unable to load application: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
2020-08-04T22:37:26.041370+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.5.0/bin/puma)
2020-08-04T22:37:26.041449+00:00 app[web.1]: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
2020-08-04T22:37:26.041494+00:00 app[web.1]: /app/config/environment.rb:5:in `<top (required)>'
I feel like the most important errors in the logs are我觉得日志中最重要的错误是
Unable to load application: ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
and和
ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
I also see /app/config/environment.rb:5
in the logs which is我还在日志中看到/app/config/environment.rb:5
是
# Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
I'm (praying) that someone else would have any ideas on what I can do here?我(祈祷)其他人会对我在这里能做什么有任何想法? I'm pretty new at working with deploying applications to heroku and so i'm not super sure what to do here.我在将应用程序部署到 heroku 方面非常陌生,所以我不太确定在这里做什么。
You have to set these keys on heroku:您必须在 heroku 上设置这些键:
heroku config:set GITHUB_USERNAME=joesmith
In this case GITHUB_USERNAME ist the set variable and you have to use that in your code so heroku knows what it should insert.在这种情况下, GITHUB_USERNAME 是设置变量,您必须在代码中使用它,以便 heroku 知道它应该插入什么。
heroku docs: "Configuration and Config Vars" heroku 文档:“配置和配置变量”
ruby guides: "How To Use Environment Variables in Ruby" ruby 指南:“如何在 Ruby 中使用环境变量”
arkency blog: "How to safely store API keys in Rails apps" arkency 博客:“如何在 Rails 应用程序中安全地存储 API 密钥”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.