Rails always sets HTTP protocol

I am running a Rails application inside Vagrant. I am trying to run the application in QA mode to reflect the deployment environment. I am doing SSL termination in a load balancer in my QA environment, so I would like to be able to run a Rails application only through http, nowhere https.

I use Devise to authenticate users. I can download my application just fine, but when I log in, the developer always wants to redirect to https. I cannot force myself to behave differently. I pinged the development assistants for help, but they had no way to share.

I tried the setup config.force_ssl = false, but that doesn't seem to matter.

I run the application under Unicorn, proxying on nginx. Any insight would be appreciated!

+4
source share
1 answer

I think adding something like thi to application.rb, this may interfere with the problem:

[
  config.action_controller.default_url_options,
  config.action_mailer.default_url_options,
  Rails.application.routes.default_url_options,
  Devise::Engine.routes.default_url_options,
  Devise::Engine.config.action_controller.default_url_options
].each do |config|

  config[:protocol] = "http#{'s' if Rails.env.production}"

end

In addition, you can override the various methods of the Devise controller by subclassing them. Therefore, if you identify the cuplrit method, you can: a) solve the root cause or b) subclass the controller, use a workaround instead.

0
source

Source: https://habr.com/ru/post/1626917/


All Articles