Saturday, July 6, 2013
Heroku Custom Domain failed to connect Facebook API
If privacy is important to you make your domain private today. The background problem of this post is :
I developed an application with FB-connect using Ruby On Rails on Heroku. Everything is working well until we face this problem : Everytime user clicks "Sign In with Facebook" , it returned R10 (boot timeout error). It didn't reach Facebook API at all (after I'm reading R10 docs).
However, when I take out the custom domain (www.my-app.com) , then replace www.my-app.com on developers.facebook.com with my-app.herokuapp.com --- you know what I mean... Then, I access the app through my-app.herokuapp.com , everything is working well. I can "Sign in with Facebook" correctly, without any problem.
How to solve such problem ?
To solve such problem, you need to follow all the steps below carefully and correctly.
- Open session_store.rb file under /config/initializers directory on your Rails application.
- Change to database for sessions instead of using cookie as sessions store for your Rails application. To do this, just match the codes below with the one on yours.
# Be sure to restart your server when you modify this file. #kevinhq::Application.config.session_store :cookie_store, :key => '_kevinhq_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") kevinhq::Application.config.session_store :active_record_store
After applying such change on your Rails application, please remember to run "rails generate session_migration". That command will produce a new migration and you need to execute it with "rake db:migrate" (as usual). At last,be sure to restart your server.
*Replace kevinhq::Application with your-app-name::Application
Conclusion (so far) :
I found the root of the problem was with session store. Using cookie as session store (which is default one), cause this problem. In other words,it cause "cookie overflow" and prevent the application to reach Facebook API when running on Heroku platform (although it can reach Facebook API when running locally).
comments powered by Disqus