diff --git a/config/initializers/50-force_https.rb b/config/initializers/50-force_https.rb new file mode 100644 index 000000000..161bc8cc4 --- /dev/null +++ b/config/initializers/50-force_https.rb @@ -0,0 +1,17 @@ +# tiny middleware to force https if needed +class Discourse::ForceHttpsMiddleware + + def initialize(app, config={}) + @app = app + end + + def call(env) + env['rack.url_scheme'] = 'https' if SiteSetting.use_https + @app.call(env) + end + +end + + +Rails.configuration.middleware.insert_before MessageBus::Rack::Middleware, Discourse::ForceHttpsMiddleware +