Skip to content

[Config] Make the listen address configurable via BIND_ADDRESS - #169

Merged
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-138-g5ni35
Aug 16, 2026
Merged

[Config] Make the listen address configurable via BIND_ADDRESS#169
LarsLaskowski merged 1 commit into
mainfrom
claude/issue-138-g5ni35

Conversation

@LarsLaskowski

@LarsLaskowski LarsLaskowski commented Aug 16, 2026

Copy link
Copy Markdown
Owner

📖 Description

Adds a BIND_ADDRESS environment variable so the server can be restricted to a specific network interface (e.g. 127.0.0.1) instead of always binding to all interfaces (0.0.0.0). This closes a gap for deployments that run a reverse proxy on the same host and want the unauthenticated API reachable only via loopback.

  • src/server/types.ts: added bindAddress: string to AppConfig.
  • src/server/config.ts: reads BIND_ADDRESS, trims it, and falls back to '0.0.0.0' when unset or whitespace-only. No further validation — an unbindable address fails at listen() time.
  • src/server/index.ts: passes config.bindAddress to app.listen(...), includes it in the startup log line, and adds a server.on('error', ...) handler so a bad address (e.g. EADDRNOTAVAIL) logs a clear fatal message and exits instead of surfacing as an unhandled 'error' event.
  • README.md: documented BIND_ADDRESS in the configuration table.
  • deploy/systemd/openhab-log-viewer.service: added a commented example next to the other optional settings.

🎫 Issues

Closes #138

👩‍💻 Reviewer Notes

Default behavior is unchanged (still binds 0.0.0.0 when BIND_ADDRESS is unset). Worth spot-checking that npm run start with BIND_ADDRESS=127.0.0.1 only accepts loopback connections, and that an invalid address (e.g. an address not present on the host) makes startup fail with the new fatal log line instead of hanging.

📑 Test Plan

  • src/server/config.test.ts: added a loadConfig bind address parsing suite covering the documented default (0.0.0.0), an explicit BIND_ADDRESS=127.0.0.1, and a whitespace-only value falling back to the default. Also asserted bindAddress in the existing defaults test.
  • src/server/routes.test.ts: updated the baseConfig() test fixture to include bindAddress so it satisfies the AppConfig type.
  • Ran npm run typecheck, npm test (152/152 passing), and npm run build locally.

✅ Checklist

General

  • I have added unit tests for my changes, per UNIT_TESTS.md.
  • I have run npm test and npm run typecheck locally and they pass.
  • I have updated the project documentation (README, ARCHITECTURE, etc.) to reflect my changes, where applicable.
  • I have read the CONTRIBUTING documentation and followed the project's code style and conventions.

Server-specific (src/server)

  • I have added or updated a module in src/server (tailer, parser, buffer, routes, SSE hub, config, etc.).
  • I have kept src/server/types.ts in sync with src/client/state.ts for any shared payload change (see ARCHITECTURE.md). — N/A, bindAddress is server-only startup config, not part of a client-facing payload.
  • I have preserved existing server-side bounds and defaults (buffer/SSE limits, poll interval clamps) unless the change explicitly targets them.

⏭ Next Steps

None.

…138)

Adds BIND_ADDRESS to bind the server to a specific interface (e.g.
127.0.0.1 for same-host reverse-proxy setups) instead of always
binding all interfaces. Defaults to 0.0.0.0 to preserve current
behavior, and a server 'error' handler now fails startup loudly on
an unbindable address instead of leaving an unhandled event.
@sonarqubecloud

Copy link
Copy Markdown

@LarsLaskowski
LarsLaskowski merged commit 064beb7 into main Aug 16, 2026
10 checks passed
@LarsLaskowski
LarsLaskowski deleted the claude/issue-138-g5ni35 branch August 16, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make the listen address configurable (BIND_ADDRESS) instead of always binding all interfaces

2 participants