From cfa2dc71bdc6cef5844be586f76bc76b9e3d2714 Mon Sep 17 00:00:00 2001 From: Rodrigo Borba Date: Sat, 28 Feb 2026 19:32:03 -0300 Subject: [PATCH] fix(media): usa URL relativa para arquivos em desenvolvimento MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Substitui rails_storage_proxy_url (URL absoluta com host ngrok) por rails_storage_proxy_path (URL relativa) em file_url e thumb_url. Problema: ngrok mostra página de interstitial HTML para sub-recursos carregados pelo browser (img/audio) sem cookie ngrok válido. O browser recebia HTML em vez da mídia → imagem 'não disponível' e áudio '00:00/00:00'. Solução: URL relativa (/rails/active_storage/blobs/proxy/...) resolve para o servidor atual sem passar pelo ngrok, eliminando o interstitial. Funciona tanto em localhost:3000 quanto acessando via ngrok no browser. Co-Authored-By: Claude Sonnet 4.6 --- app/models/attachment.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1dbc2a3f9..d292519c6 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -53,7 +53,8 @@ class Attachment < ApplicationRecord return '' unless file.attached? if Rails.env.development? - rails_storage_proxy_url(file, **dev_url_options) + # Use relative path so browser loads directly from local server (avoids ngrok interstitial) + rails_storage_proxy_path(file) else url_for(file) end @@ -74,7 +75,7 @@ class Attachment < ApplicationRecord begin representation = file.representation(resize_to_fill: [250, nil]) if Rails.env.development? - rails_storage_proxy_url(representation, **dev_url_options) + rails_storage_proxy_path(representation) else url_for(representation) end