Raj*_*Raj 13 ruby ssl ruby-on-rails ruby-on-rails-4
我需要在我的应用程序中的所有路由上强制使用SSL,除了message#new控制器.
在config/environments/production.rb,我有:
config.force_ssl = true
Run Code Online (Sandbox Code Playgroud)
现在所有路由都重定向到https,现在我想为message#new控制器禁用它.
有谁知道如何在Rails 4+应用程序中禁用特定控制器的强制SSL?
kuc*_*hbe 20
根据以下文档应该工作(但仅适用于rails> 5版本):
config.ssl_options = {
redirect: {
exclude: -> request { request.path =~ /healthcheck/ }
}
}
Run Code Online (Sandbox Code Playgroud)
skip_before_action :verify_authenticity_token
force_ssl except: [:index,:create]
Run Code Online (Sandbox Code Playgroud)
它对我有用.
| 归档时间: |
|
| 查看次数: |
4705 次 |
| 最近记录: |