0
votes

I can use my rails app in local and connect with facebook using rails devise and omniauth, but when i want to deploy it, the facebook callback port is wrong. After clicking on "login with facebook", it redirects me to facebook when i can enter my login, then it calls back my app like this :

http://myapp.cleverapps.io:8080/users/auth/facebook/callback?code=thelongcode#_=_

but it says "Oops! Google Chrome could not connect to myapp.cleverapps.io:8080" Meanwhile when i call

http://myapp.cleverapps.io/users/auth/facebook/callback?code=thelongcode#_=_

it works.

I don't understand why it is working in localhost:3000 and not on my deployment environment.

Why is omniauth adding 8080 to the url? Can i set it to 80 in this line for example?

devise_for :users, [...] :controllers => {[...] :omniauth_callbacks => "users/omniauth_callbacks"}
1
Did you manage to resolve the problem? I've got the same, but on port 1018.. - Jakoss

1 Answers

0
votes
  1. Login at https://developers.facebook.com.
  2. Click menu 'Apps' and click your app from the dropdown.
  3. Click 'Settings'. Edit your 'Site URL': i.e. http://myapp.cleverapps.io/ (alternatively also try http://myapp.cleverapps.io:8080/, although this alternative may be the current setting and be the underlying cause of the issue)
  4. Edit your 'Mobile Site URL': i.e. http://localhost:3000/

With these updated settings you should be able to login successfully with Facebook OmniAuth in both development and production.

Additionally, double check that your configuration allows for use of the Facebook ID and secret (stored in your .ENV file) in production (this may be set in /config/initializers/devise.rb)

i.e. devise.rb

  if Rails.env == 'development' || Rails.env == 'production'
      config.omniauth :facebook, ENV['FACEBOOK_ID'], ENV['FACEBOOK_SECRET']
  end

i.e. .env

FACEBOOK_ID=123456789876543
FACEBOOK_SECRET=1aa11a111111a1aaa1a1aa11aaa11a11