Skip to content

Instantly share code, notes, and snippets.

@tatat
Created July 5, 2013 05:16
Show Gist options
  • Save tatat/5932012 to your computer and use it in GitHub Desktop.
Save tatat/5932012 to your computer and use it in GitHub Desktop.
OmniAuth.config.full_host = ->(env) {
scheme = if env['HTTPS'] == 'on' or env['HTTP_X_FORWARDED_SSL'] == 'on'
'https'
elsif env['HTTP_X_FORWARDED_PROTO'].present?
env['HTTP_X_FORWARDED_PROTO'].split(',').first.strip
else
env['rack.url_scheme']
end
hostname = env['HTTP_X_FORWARDED_HOST'].present? ? env['HTTP_X_FORWARDED_HOST'] : env['HTTP_HOST']
port = env['HTTP_X_FORWARDED_PORT'].present? ? ":#{env['HTTP_X_FORWARDED_PORT']}" : ''
"#{scheme}://#{hostname}#{port}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment