Skip to content

Commit b6e9b5d

Browse files
dadachiclaude
andcommitted
Fall back to localhost for mailer host when HOST is unset
ENV.fetch("HOST") at config-load time crashed any Rails invocation that doesn't go through Foreman (bin/rails test, console, setup, CI) — .env is loaded only when bin/dev runs via Foreman/Overmind. Default the mailer URL host to "localhost" so boot succeeds in those paths; Procfile.dev still uses \${HOST:?...} so the dev server itself won't start without an explicit Wi-Fi IP. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3469bff commit b6e9b5d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

config/environments/development.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838

3939
config.action_mailer.perform_caching = false
4040

41-
config.action_mailer.default_url_options = {host: ENV.fetch("HOST"), port: ENV.fetch("PORT", 3000).to_i}
41+
# HOST is only loaded into ENV by Foreman under `bin/dev`; direct Rails
42+
# invocations (console, test, setup, CI) don't see .env, so default to
43+
# localhost for the mailer so boot succeeds. `Procfile.dev` still refuses
44+
# to start the dev server without an explicit HOST.
45+
config.action_mailer.default_url_options = {host: ENV.fetch("HOST", "localhost"), port: ENV.fetch("PORT", 3000).to_i}
4246

4347
# Print deprecation notices to the Rails logger.
4448
config.active_support.deprecation = :log

0 commit comments

Comments
 (0)