diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 64abc8b4f..df62f8214 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -12,7 +12,9 @@ def redirect_callbacks # derive target redirect route from 'resource_class' param, which was set # before authentication. devise_mapping = request.env['omniauth.params']['resource_class'].underscore.to_sym - redirect_route = "/#{Devise.mappings[devise_mapping].as_json["path"]}/#{params[:provider]}/callback" + redirect_route = File.join(request.protocol, request.host_with_port, Devise.mappings[devise_mapping].as_json["path"], + params[:provider], 'callback') + # preserve omniauth info for success route. ignore 'extra' in twitter # auth response to avoid CookieOverflow.