fix(demo): self-call host respects config.server.host#44
Merged
Conversation
Closes audit #14. The demo route makes loopback fetch calls to its own server (/supported, /verify, /settle, etc. -- a 7-step live demo). The URL was hardcoded to http://127.0.0.1:${port}, which works because we listen on 0.0.0.0 in production and 127.0.0.1 inside the container reaches the same process. But it's brittle: any operator who changes server.host to a specific IP would break the demo. Fix: read fastify.config.server.host, and substitute 127.0.0.1 when the configured host is the wildcard 0.0.0.0 (since the wildcard isn't a valid client address). No production behaviour change today -- server.host stays 0.0.0.0 so the resulting URL is identical (127.0.0.1:port). The fix simply makes the route honor whatever the operator configures. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes audit #14. The demo route's loopback fetch to its own server hardcoded `http://127.0.0.1:\${port}\`, which works in production (we listen on 0.0.0.0 so 127.0.0.1 inside the container resolves to the same process) but breaks if the operator ever sets `server.host` to a specific IP.
Fix is one line of logic: read `config.server.host`, and substitute `127.0.0.1` only when the configured host is the wildcard `0.0.0.0` (since wildcard isn't a valid client address).
Test plan
🤖 Generated with Claude Code