Skip to content

Comments

Make bind address configurable for app dev server#6872

Open
lmcrean wants to merge 5 commits intoShopify:lmcrean-6355from
lmcrean:lmcrean-6355
Open

Make bind address configurable for app dev server#6872
lmcrean wants to merge 5 commits intoShopify:lmcrean-6355from
lmcrean:lmcrean-6355

Conversation

@lmcrean
Copy link

@lmcrean lmcrean commented Feb 20, 2026

Adds configurable bind address support to the shopify app dev command to enable Docker container development workflows.

Problem

  • Fixes [Feature]: Make bind address configurable for local servers #6355
  • Recent CLI versions hardcode localhost binding for app dev servers for security
  • Docker containers require 0.0.0.0 binding to accept connections from host machine
  • Theme dev server already supports --host flag, but app dev server does not
  • Breaks containerized development setups (working version was 3.83.3)

Solution

  • Add --host flag to shopify app dev command with SHOPIFY_FLAG_HOST env var support
  • Update proxy server setup to use configurable host instead of hardcoded 'localhost'
  • Maintain secure default (127.0.0.1) while enabling Docker flexibility
  • Match existing theme dev server pattern for consistency

Changes Made

1. Added host flag to app dev command

  • File: packages/app/src/cli/commands/app/dev.ts
  • Added --host flag with environment variable support
  • Default: 127.0.0.1 (maintains security)
  • Override: 0.0.0.0 (enables Docker containers)

2. Updated proxy server to use configurable host

  • File: packages/app/src/cli/services/dev/processes/setup-dev-processes.ts
  • Changed hardcoded 'localhost' to use passed host parameter
  • Added host parameter to proxy server setup function

Usage Examples

For Docker containers:

SHOPIFY_FLAG_HOST=0.0.0.0 shopify app dev
# or
shopify app dev --host=0.0.0.0

For normal development (default):

shopify app dev  # Still binds to localhost by default

Testing

Unit Tests

Added comprehensive unit test coverage in packages/app/src/cli/services/dev/processes/setup-dev-processes.test.ts:

New Test: proxy server process includes host parameter when configured for Docker

  • Purpose: Verifies that the proxy server correctly uses the host parameter when set to 0.0.0.0 for Docker compatibility
  • Test setup: Creates a dev configuration with host: '0.0.0.0' simulating Docker usage
  • Verification: Confirms the proxy server process options include the correct host value
  • Location: Lines 85-150 in the test file

Updated Existing Tests

All existing tests were updated to include the required host: 'localhost' parameter in commandOptions to satisfy TypeScripts' requirements for the Devoptions interface. Users get localhost by default so no action needed.

Test Commands

# Run unit tests for the setup-dev-processes module
pnpm test packages/app/src/cli/services/dev/processes/setup-dev-processes.test.ts

Manual Testing

  • Verify default behavior unchanged (binds to localhost)
  • Verify --host=0.0.0.0 enables external connections
  • Verify SHOPIFY_FLAG_HOST environment variable works
  • Test Docker container setup with port forwarding
  • Ensure backwards compatibility

No Breaking Changes

This is a feature addition that maintains 100% backward compatibility. Users who don't need Docker support will see zero changes in behavior. Only users who specifically want to bind to a different network interface need to use the new --host flag.

Previously #6396; this PR appears ready to merge

…documentation. This change ensures consistency across the application and improves clarity for users regarding the network interface settings.
…est to enhance readability and maintain consistency in configuration formatting.
@lmcrean lmcrean requested a review from a team as a code owner February 20, 2026 11:37
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.

1 participant