Help us understand the problem. What is going on with this article?

OmniAuthのcallback先を動的に変更

More than 5 years have passed since last update.
config/initializers/omniauth.rb
# encoding: utf-8

require 'omniauth-openid'
require 'openid/store/filesystem'

# callback先のドメインを現在のものに合わせる => reverse proxy用
OmniAuth.config.full_host = lambda do |env|
  # http or https
  scheme         = env['rack.url_scheme']

  # アプリケーションサーバーのアドレス
  local_host     = env['HTTP_HOST']

  # リバースプロキシサーバーのアドレス: リバースプロキシ側でヘッダーを送られないと意味がない
  forwarded_host = env['HTTP_X_FORWARDED_HOST']

  # リバースプロキシしてるかどうか
  forwarded_host.blank? ? "#{scheme}://#{local_host}" : "#{scheme}://#{forwarded_host}"
end

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, 'xxx', 'xxx'
  provider :facebook, 'xxx', 'xxx'

  # generic openid
  provider :open_id, :store => OpenID::Store::Filesystem.new('/tmp')
  provider :open_id, :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
end

mosson
CREATIVE SURVEYというサービスを作っています。
https://creativesurvey.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away