Skip to content

Commit 39ff3f0

Browse files
committed
fix: S3 presign host parsing for schemeless asset hosts
Normalize S3_ASSET_HOST before URI parsing to prevent runtime boot failures when the host is provided without a scheme. Signed-off-by: Omar <omar.brbutovic@secomind.com>
1 parent ea0b732 commit 39ff3f0

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

backend/config/runtime.exs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,16 @@ if config_env() in [:prod, :test] do
147147
s3_presign_host_config =
148148
if storage_type != "azure" do
149149
asset_host = s3.asset_host || "http://localhost:9000"
150-
uri = URI.parse(asset_host)
151-
%{scheme: uri.scheme <> "://", host: uri.host, port: uri.port || 80}
150+
151+
normalized_asset_host =
152+
if String.contains?(asset_host, "://"),
153+
do: asset_host,
154+
else: s3.scheme <> asset_host
155+
156+
uri = URI.parse(normalized_asset_host)
157+
port = uri.port || if(s3.scheme == "https://", do: 443, else: 80)
158+
159+
%{scheme: s3.scheme, host: uri.host || "localhost", port: port}
152160
end
153161

154162
config :azurex, Azurex.Blob.Config,

0 commit comments

Comments
 (0)