Add BASE_URL environment variable

When running a Docker deployment, we need a way to set the app's base
URL. Otherwise links in emails, or generated in jobs etc., can not be
correctly constructed.
This commit is contained in:
Kevin McConnell
2025-12-19 12:14:15 +00:00
parent f9409c15a0
commit 407f2a3a6a
4 changed files with 23 additions and 0 deletions
+11
View File
@@ -21,6 +21,17 @@ Rails.application.configure do
}
end
# Base URL for links in emails and other external references.
# Set BASE_URL to your instance's public URL (e.g., https://fizzy.example.com)
if base_url = ENV["BASE_URL"].presence
uri = URI.parse(base_url)
url_options = { host: uri.host, protocol: uri.scheme }
url_options[:port] = uri.port if uri.port != uri.default_port
routes.default_url_options = url_options
config.action_mailer.default_url_options = url_options
end
# Code is not reloaded between requests.
config.enable_reloading = false