Skip to content

cli: bind local backends to loopback by default - #204

Open
CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/dev-interface-200
Open

CloudCorpRecords wants to merge 1 commit into
convex:mainfrom
CloudCorpRecords:fix/dev-interface-200

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

Fixes #200

Root cause

runLocalBackend in src/cli/lib/localDeployment/run.ts built the backend's commandArgs with --port, --site-proxy-port, --instance-name, etc., but never passed --interface. The binary's default is 0.0.0.0, so every convex dev local deployment exposed its API port and HTTP-actions port to the whole network, even though the CLI only ever talks to the backend on 127.0.0.1.

The change

  • runLocalBackend now passes --interface 127.0.0.1 when starting the local backend (files: src/cli/lib/localDeployment/run.ts).
  • The interface is overridable with the CONVEX_LOCAL_BACKEND_INTERFACE env var for machines that deliberately serve a local deployment to other devices, mirroring the existing CONVEX_LOCAL_BACKEND_STARTUP_TIMEOUT_SECS pattern. A blank value crashes loudly instead of silently binding to every interface.
  • The flag is added in the isLatestVersion section (the repo's own compatibility pattern) so the CLI keeps working with older backend binaries that may not support --interface.

Test evidence

  • New src/cli/lib/localDeployment/run.test.ts: 3/3 passing (default is 127.0.0.1, env override passes through, blank value is rejected).
  • npx tsc --noEmit --emitDeclarationOnly false: clean, exit 0.

Honest limits

  • The actual bind behavior could not be exercised against a live convex-local-backend binary from this environment; the fix is verified at the arg-construction and unit level. If the team prefers a --interface commander flag on convex dev instead of (or in addition to) the env var, happy to switch.

Signed-off-by: Rene Turcios 95189389+CloudCorpRecords@users.noreply.github.com

runLocalBackend started convex-local-backend without --interface, so the
binary's 0.0.0.0 default exposed the dev API and HTTP-actions ports to the
whole network. Pass --interface 127.0.0.1, overridable with
CONVEX_LOCAL_BACKEND_INTERFACE for machines that deliberately serve a
local deployment. Fixes convex#200.

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>
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.

Local deployments bind the backend to 0.0.0.0: convex dev passes no --interface

1 participant