mirror of
https://github.com/discourse/discourse.git
synced 2025-03-22 11:35:35 +08:00
FIX: Use asset_hostnames in rails_multisite
We want to respond to the x-forwarded-for host from the CDN too.
This commit is contained in:
parent
b47b640598
commit
6e69c25134
@ -281,7 +281,7 @@ GEM
|
||||
rails_failover (0.5.7)
|
||||
activerecord (~> 6.0)
|
||||
railties (~> 6.0)
|
||||
rails_multisite (2.4.0)
|
||||
rails_multisite (2.5.0)
|
||||
activerecord (> 5.0, < 7)
|
||||
railties (> 5.0, < 7)
|
||||
railties (6.0.3.3)
|
||||
|
@ -112,6 +112,13 @@ class GlobalSetting
|
||||
@use_s3 = nil
|
||||
end
|
||||
|
||||
def self.cdn_hostnames
|
||||
hostnames = []
|
||||
hostnames << URI.parse(cdn_url).host if cdn_url.present?
|
||||
hostnames << cdn_origin_hostname if cdn_origin_hostname.present?
|
||||
hostnames
|
||||
end
|
||||
|
||||
def self.database_config
|
||||
hash = { "adapter" => "postgresql" }
|
||||
|
||||
|
@ -21,9 +21,14 @@ if Rails.env != 'development' || ENV['TRACK_REQUESTS']
|
||||
end
|
||||
|
||||
if Rails.configuration.multisite
|
||||
RailsMultisite::ConnectionManagement.asset_hostname =
|
||||
GlobalSetting.cdn_origin_hostname ||
|
||||
Discourse::Application.config.database_configuration[Rails.env]["host_names"].first
|
||||
assets_hostnames = GlobalSetting.cdn_hostnames
|
||||
|
||||
if assets_hostnames.empty?
|
||||
assets_hostnames =
|
||||
Discourse::Application.config.database_configuration[Rails.env]["host_names"]
|
||||
end
|
||||
|
||||
RailsMultisite::ConnectionManagement.asset_hostnames = assets_hostnames
|
||||
|
||||
# Multisite needs to be first, because the request tracker and message bus rely on it
|
||||
Rails.configuration.middleware.unshift RailsMultisite::Middleware, RailsMultisite::DiscoursePatches.config
|
||||
|
Loading…
x
Reference in New Issue
Block a user