使用相同的 facebook apikey 进行 Heroku 生产和本地开发
我想在本地计算机上测试我的 Rails 应用程序,并使其在 Heroku 上运行。但是,如果我在 facebook 应用程序设置中的“网站”字段中指定我的 IP 地址,那么我的 heroku 就会崩溃,反之亦然。有什么方法可以让它们使用相同的 API 密钥吗?
如果没有,我如何告诉 Omniauth 在开发环境中使用一个 api 密钥,在生产环境中使用另一个 api 密钥?谢谢!
I would like to test my rails app on my local machine and also have it functional on heroku. However, if I specify my IP address for the "Website" field on the facebook app settings, then my heroku breaks and vice versa. Is there any way to have them both work using the same API Key?
If not, how do I tell Omniauth to use one api key for the development environment and another for the production environment? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用单独的 FB 应用程序用于开发(本地)和生产(Heroku)。
从环境中读取密钥,例如:
ENV["FACEBOOK_APP_ID"]
ENV["FACEBOOK_SECRET"]
然后使用
heroku config:add
在 Heroku 上的配置中设置密钥/凭据。在本地使用 foreman 运行您的应用程序并在 .env 文件中设置开发密钥/信用。 http://blog.daviddollar.org/2011/05/06/introducing -foreman.html
请记住,FB 要求您使用 SSL,因此您需要在本地设置一些可以处理 SSL 请求的内容。
Use a separate FB app for dev (local) and for production (Heroku).
Read the key out of the environment like:
ENV["FACEBOOK_APP_ID"]
ENV["FACEBOOK_SECRET"]
Then set the key/creds in your config on Heroku using
heroku config:add
.Locally use foreman to run your app and set the dev key/creds in a .env file. http://blog.daviddollar.org/2011/05/06/introducing-foreman.html
Keep in mind that FB requires you to use SSL so you'll need to setup something locally that can handle SSL requests.
您要么必须创建另一个用于开发的 Facebook 应用程序(这就是我所做的),要么必须在 /etc/hosts 文件中创建一个条目,将 Heroku 应用程序的主机名指向您的本地计算机。
You will either have to create another development Facebook application for development, which is what I do, or you will have to create an entry in your /etc/hosts file that points the hostname of your Heroku app to you local machine.