Skip to content

Commit 05f4d70

Browse files
dadachiclaude
andcommitted
Make dev server bind env-driven via HOST/PORT
Replace hardcoded 192.168.1.21 with HOST/PORT env vars loaded from .env by Foreman. Adds .env.sample template and updates docs accordingly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 94b5b4c commit 05f4d70

6 files changed

Lines changed: 11 additions & 4 deletions

File tree

.env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copy to .env and edit. Loaded by Foreman when running `bin/dev`.
2+
3+
# Rails server bind address and port. Use your LAN IP (e.g. 192.168.1.6) for
4+
# mobile-device-on-LAN access; use 127.0.0.1 for loopback-only dev.
5+
HOST=127.0.0.1
6+
PORT=3000

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# Ignore all environment files (except templates).
1111
/.env*
1212
!/.env*.erb
13+
!/.env.sample
1314

1415
# Ignore all logfiles and tempfiles.
1516
/log/*

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ bin/rails dbconsole # Database console
9696
- Run tests: `bin/rails test` (205 tests, 402 assertions)
9797

9898
### Development Server Configuration
99-
- Server binds to specific IP: `192.168.1.21:3000` (not localhost)
99+
- Server bind and mailer host are env-driven via `HOST`/`PORT` in `.env` (defaults `127.0.0.1:3000`)
100100
- Mailbin for email testing at `/mailbin`
101101
- Admin interface at `/madmin`
102102
- Tailwind CSS compiled by tailwindcss-rails gem

Procfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: bin/rails server -p $PORT -b 192.168.1.21
1+
web: bin/rails server -p ${PORT:-3000} -b ${HOST:-127.0.0.1}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bin/setup
8585

8686
## Running NativeAppTemplate API on localhost
8787

88-
Replace the IP address `192.168.1.21` with your localhost IP address in `Procfile.dev` and `config/environments/development.rb`.
88+
Copy `.env.sample` to `.env` and set `HOST` (and optionally `PORT`) to control the server bind address and mailer URL host. Defaults to `127.0.0.1:3000`. For mobile-device-on-LAN access, set `HOST=<your-lan-ip>`. Foreman auto-loads `.env` under `bin/dev`.
8989

9090
To run your application, you'll use the `bin/dev` command:
9191

config/environments/development.rb

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

3939
config.action_mailer.perform_caching = false
4040

41-
config.action_mailer.default_url_options = {host: "192.168.1.21", port: ENV.fetch("PORT", 3000).to_i}
41+
config.action_mailer.default_url_options = {host: ENV.fetch("HOST", "127.0.0.1"), port: ENV.fetch("PORT", 3000).to_i}
4242

4343
# Print deprecation notices to the Rails logger.
4444
config.active_support.deprecation = :log

0 commit comments

Comments
 (0)