FIX: include onebox default options in development environment

This commit is contained in:
Arpit Jalan 2019-11-07 15:42:11 +05:30
parent 9c1a713c6e
commit 6a417c308f
2 changed files with 14 additions and 9 deletions

View File

@ -1,7 +1,16 @@
# frozen_string_literal: true # frozen_string_literal: true
Onebox.options = { if Rails.env.development? && SiteSetting.port.to_i > 0
twitter_client: TwitterApi, Onebox.options = {
redirect_limit: 3, twitter_client: TwitterApi,
user_agent: "Discourse Forum Onebox v#{Discourse::VERSION::STRING}" 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

View File

@ -290,10 +290,6 @@ module Oneboxer
options[:cookie] = fd.cookie if fd.cookie 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) r = Onebox.preview(uri.to_s, options)
{ onebox: r.to_s, preview: r&.placeholder_html.to_s } { onebox: r.to_s, preview: r&.placeholder_html.to_s }