mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FEATURE: Optionally allow a separate s3_asset_cdn_url
to be specified (#19284)
If configured, this will be used for static JS assets which are stored on S3. This can be useful if you want to use different CDN providers/configuration for Uploads and JS
This commit is contained in:
@ -95,9 +95,10 @@ module ApplicationHelper
|
||||
path = ActionController::Base.helpers.asset_path("#{script}.js")
|
||||
|
||||
if GlobalSetting.use_s3? && GlobalSetting.s3_cdn_url
|
||||
resolved_s3_asset_cdn_url = GlobalSetting.s3_asset_cdn_url.presence || GlobalSetting.s3_cdn_url
|
||||
if GlobalSetting.cdn_url
|
||||
folder = ActionController::Base.config.relative_url_root || "/"
|
||||
path = path.gsub(File.join(GlobalSetting.cdn_url, folder, "/"), File.join(GlobalSetting.s3_cdn_url, "/"))
|
||||
path = path.gsub(File.join(GlobalSetting.cdn_url, folder, "/"), File.join(resolved_s3_asset_cdn_url, "/"))
|
||||
else
|
||||
# we must remove the subfolder path here, assets are uploaded to s3
|
||||
# without it getting involved
|
||||
@ -105,7 +106,7 @@ module ApplicationHelper
|
||||
path = path.sub(ActionController::Base.config.relative_url_root, "")
|
||||
end
|
||||
|
||||
path = "#{GlobalSetting.s3_cdn_url}#{path}"
|
||||
path = "#{resolved_s3_asset_cdn_url}#{path}"
|
||||
end
|
||||
|
||||
# assets needed for theme testing are not compressed because they take a fair
|
||||
|
Reference in New Issue
Block a user