diff --git a/config/initializers/100-onebox_options.rb b/config/initializers/100-onebox_options.rb index e9d0f21c712..d98886e2ba3 100644 --- a/config/initializers/100-onebox_options.rb +++ b/config/initializers/100-onebox_options.rb @@ -1,7 +1,16 @@ # frozen_string_literal: true -Onebox.options = { - twitter_client: TwitterApi, - redirect_limit: 3, - user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}" -} +if Rails.env.development? && SiteSetting.port.to_i > 0 + Onebox.options = { + twitter_client: TwitterApi, + redirect_limit: 3, + user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}", + allowed_ports: [80, 443, SiteSetting.port.to_i] + } +else + Onebox.options = { + twitter_client: TwitterApi, + redirect_limit: 3, + user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}" + } +end diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb index 96245cf820a..fba6704045b 100644 --- a/lib/oneboxer.rb +++ b/lib/oneboxer.rb @@ -290,10 +290,6 @@ module Oneboxer options[:cookie] = fd.cookie if fd.cookie - if Rails.env.development? && SiteSetting.port.to_i > 0 - Onebox.options = { allowed_ports: [80, 443, SiteSetting.port.to_i] } - end - r = Onebox.preview(uri.to_s, options) { onebox: r.to_s, preview: r&.placeholder_html.to_s }