From 5c41bb07479040dbc5f250f964a7d6c5d2ab1933 Mon Sep 17 00:00:00 2001 From: dongzhimin Date: Sun, 24 Aug 2025 20:10:51 +0800 Subject: [PATCH] fixed issue would cause bucket name and endpoint leaking --- app/helpers/routing_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/helpers/routing_helper.rb b/app/helpers/routing_helper.rb index b5d090db49e..d419f076c45 100644 --- a/app/helpers/routing_helper.rb +++ b/app/helpers/routing_helper.rb @@ -23,7 +23,8 @@ module RoutingHelper def expiring_asset_url(attachment, expires_in) case Paperclip::Attachment.default_options[:storage] when :s3, :azure - attachment.expiring_url(expires_in.to_i) + url = attachment.expiring_url(expires_in.to_i) + ENV.key?('S3_ALIAS_HOST') ? url.sub("#{ENV.fetch('S3_ENDPOINT')}/#{ENV.fetch('S3_BUCKET')}", "https://#{ENV.fetch('S3_ALIAS_HOST')}") : url when :fog if Paperclip::Attachment.default_options.dig(:fog_credentials, :openstack_temp_url_key).present? attachment.expiring_url(expires_in.from_now)