skip/disable force_ssl for particular controller in rails

后端 未结 3 1367
夕颜
夕颜 2020-12-17 16:53

I need to force SSL on all routes in my application except for message#new controller.

In config/environments/production.rb, I have:

<
相关标签:
3条回答
  • 2020-12-17 16:56

    Do this in MessagesController.rb -

      force_ssl except: [:new]
    
    0 讨论(0)
  • 2020-12-17 17:05
    skip_before_action :verify_authenticity_token
    force_ssl except: [:index,:create]
    

    Its worked for me.

    0 讨论(0)
  • 2020-12-17 17:06

    according to documentation following should work (but only for rails > 5 version):

    config.ssl_options = {
      redirect: {
        exclude: -> request { request.path =~ /healthcheck/ }
      }
    }
    
    0 讨论(0)
提交回复
热议问题