我正在尝试覆盖为我的应用配置的CDN主机,仅针对特定资产,但它似乎忽略了该选项。
module ApplicationHelper
def icon(name, *opts)
content_tag :svg, class: "icon", "aria-hidden" => true do
# Use same origin asset host to avoid cross-origin issues with the <use> element.
url = image_url("icons/entypo.svg##{name.to_s.dasherize}", host: "example.com")
# Expected => https://example.com/assets/icons/entypo-14602e471cad33414596c56d831c5b8cdcec9477829b9eb6d34221faac7bb54d.svg
# Actual => https://cdn.example.com/assets/icons/entypo-14602e471cad33414596c56d831c5b8cdcec9477829b9eb6d34221faac7bb54d.svg
content_tag :use, nil, "xmlns:xlink" => "http://www.w3.org/1999/xlink", "xlink:href" => url
end
end
end
Example::Application.configure do
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
config.asset_host = "example.com"
config.action_controller.asset_host = ENV["AWS_CLOUDFRONT_DOMAIN"] # => cdn.example.com
config.action_mailer.asset_host = ENV["AWS_CLOUDFRONT_DOMAIN"] # => cdn.example.com
end