From 216348d361dcd8d4c0042719334c6e6a07e1e94a Mon Sep 17 00:00:00 2001 From: Ahmed Ejaz Date: Wed, 19 Feb 2025 05:09:19 +0500 Subject: [PATCH 1/2] fix base urls for assets in development --- .env.development | 2 +- app/views/layouts/mailer.html.haml | 2 +- config/environments/development.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.env.development b/.env.development index 8742946d7c..42f7145e8d 100644 --- a/.env.development +++ b/.env.development @@ -18,7 +18,7 @@ OFN_REDIS_URL="redis://localhost:6379/1" OFN_REDIS_JOBS_URL="redis://localhost:6379/2" OFN_REDIS_CABLE_URL="redis://localhost:6379/0" -SITE_URL="0.0.0.0:3000" +SITE_URL="localhost:3000" # Deactivate rack-timeout in development. # https://github.com/zombocom/rack-timeout#configuring diff --git a/app/views/layouts/mailer.html.haml b/app/views/layouts/mailer.html.haml index 12c654b3d1..f12aad1928 100644 --- a/app/views/layouts/mailer.html.haml +++ b/app/views/layouts/mailer.html.haml @@ -16,7 +16,7 @@ %table{:bgcolor => "#f2f2f2"} %tr %td - %img{src: ContentConfig.url_for(:footer_logo), width: "144", height: "50"}/ + = image_tag ContentConfig.url_for(:footer_logo), width: "144", height: "50" %td{:align => "right"} %h6.collapse = Spree::Config[:site_name] diff --git a/config/environments/development.rb b/config/environments/development.rb index 3dcbe29076..94ef75a309 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -69,8 +69,9 @@ Openfoodnetwork::Application.configure do # Show emails using Letter Opener config.action_mailer.delivery_method = :letter_opener - config.action_mailer.default_url_options = { host: "0.0.0.0:3000" } + config.action_mailer.default_url_options = { host: "localhost:3000" } config.action_mailer.asset_host = "http://localhost:3000" + config.asset_host = "http://localhost:3000" config.log_level = ENV.fetch("DEV_LOG_LEVEL", :debug) end From 691e988fbb9321035c7be2b3e52292cc3e44996c Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 19 Feb 2025 13:29:34 +1100 Subject: [PATCH 2/2] Fix Roadie dev config to inline CSS in emails Roadie doesn't work with asset host: * https://github.com/Mange/roadie-rails?tab=readme-ov-file#known-issues And we don't need it. --- app/mailers/application_mailer.rb | 3 ++- config/environments/development.rb | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index 00a6a7dc6c..d5cc7a3c3c 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -18,6 +18,7 @@ class ApplicationMailer < ActionMailer::Base def roadie_options # This lets us specify assets using relative paths in email templates - super.merge(url_options: { host: URI(main_app.root_url).host }) + url = URI(main_app.root_url) + super.merge(url_options: { host: url.host, port: url.port }) end end diff --git a/config/environments/development.rb b/config/environments/development.rb index 94ef75a309..f5b71d0e1c 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -70,8 +70,6 @@ Openfoodnetwork::Application.configure do # Show emails using Letter Opener config.action_mailer.delivery_method = :letter_opener config.action_mailer.default_url_options = { host: "localhost:3000" } - config.action_mailer.asset_host = "http://localhost:3000" - config.asset_host = "http://localhost:3000" config.log_level = ENV.fetch("DEV_LOG_LEVEL", :debug) end