Skip to content

fix(refine): bind relay to loopback by default - #5

Open
Osamaali313 wants to merge 1 commit into
Jakubantalik:mainfrom
Osamaali313:bind-relay-loopback
Open

fix(refine): bind relay to loopback by default#5
Osamaali313 wants to merge 1 commit into
Jakubantalik:mainfrom
Osamaali313:bind-relay-loopback

Conversation

@Osamaali313

Copy link
Copy Markdown

What

refine/server/relay.mjs starts the relay with:

server.listen(PORT, () => { ... });

With no host argument, Node binds to 0.0.0.0 / :: — i.e. all network interfaces, not just localhost. Since npx transitions-refine live is typically run inside a project on whatever network the machine is on, the relay ends up reachable from other devices on the LAN.

That matters here because the relay isn't a passive data server — on the LLM path it answers jobs by spawning the user's coding agent to read and edit their source. It should only be reachable from the same machine. Everything else in the codebase already assumes loopback: the CLI's health / shutdown / recheck probes all hit 127.0.0.1 (refine/bin/cli.mjs), and the logs/inject examples all say localhost.

Change

Default the bind host to 127.0.0.1, with an opt-in override for anyone who intentionally wants a wider bind:

const HOST = process.env.REFINE_RELAY_HOST || "127.0.0.1";
server.listen(PORT, HOST, () => { ... });

One line of behavior change; loopback clients are unaffected.

Verification

  • node --check refine/server/relay.mjs passes.
  • Confirmed the bind change: listen(PORT) reports server.address().address === "::", while listen(PORT, "127.0.0.1") reports "127.0.0.1". Local curl http://127.0.0.1:7331/health still returns 200.

Related (not in this PR)

Separately, the relay sends Access-Control-Allow-Origin: *, so a page in a browser can also reach it cross-origin. That one needs a design decision (reflect an allowlisted origin, or a per-session token minted in inject.js and required on /jobs) rather than a mechanical change, so I've left it out of this PR — happy to help with it as a follow-up if you'd like.

The relay called server.listen(PORT) with no host, which binds to
0.0.0.0 / :: (all interfaces). Since the relay is a local dev daemon
that answers jobs by spawning the user's coding agent, it should only be
reachable from the same machine. Every other client already assumes
loopback (the CLI health/shutdown/recheck probes all hit 127.0.0.1).

Default the bind host to 127.0.0.1, with a REFINE_RELAY_HOST env var to
opt back into a wider bind for anyone who intentionally needs to reach it
from another device.
Copilot AI lite review requested due to automatic review settings August 10, 2026 20:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants