Skip to content

Conversation

@lmcrean
Copy link

@lmcrean lmcrean commented Sep 14, 2025

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.

- Introduced a new `host` flag in the dev command to specify the network interface for the web server, defaulting to 'localhost'.
- Updated the `DevOptions` interface to include the `host` property.
- Modified the setup of proxy server processes to utilize the new `host` option.
- Renamed `startProxyServer` to `proxyService` for clarity in the proxy server function.
@lmcrean lmcrean marked this pull request as ready for review September 14, 2025 08:41
@lmcrean lmcrean requested a review from a team as a code owner September 14, 2025 08:41
@lmcrean lmcrean requested a review from a team as a code owner September 20, 2025 13:54
- Add missing directory and update properties to DevOptions test objects
- Add missing config property to TestAppWithConfigOptions calls
- Add missing partnerUrlsUpdated property to DevConfig setupDevProcesses calls
- Update CLI documentation and manifest for --host flag
@theo-styles-radiant
Copy link

any eta when this will be looked at? It's blocking me working on an app that uses docker

@github-actions
Copy link
Contributor

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
→ If there's no activity within a week, then a bot will automatically close this.
Thanks for helping to improve Shopify's dev tooling and experience.

@lmcrean
Copy link
Author

lmcrean commented Nov 15, 2025

can someone review this PR please?

Copy link
Contributor

@karreiro karreiro left a comment

Choose a reason for hiding this comment

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

Thank you very much for this PR, @lmcrean!

I've made just one suggestion to ensure the flags are consistent. :)

Additionally, could you please run pnpm changeset add? This will allow us to include a changeset for this feature.

Thanks again for your contribution! 🚀

@karreiro karreiro requested a review from isaacroldan November 18, 2025 07:12
@karreiro karreiro mentioned this pull request Nov 18, 2025
@lmcrean
Copy link
Author

lmcrean commented Nov 26, 2025

Thank you for the professional notes @karreiro @isaacroldan

Just confirming that this is in my pipeline, it appears to be nearly there, I'll be engaging with it during end of December/ early Jan

@github-actions
Copy link
Contributor

This PR seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
→ If there's no activity within a week, then a bot will automatically close this.
Thanks for helping to improve Shopify's dev tooling and experience.

@lmcrean
Copy link
Author

lmcrean commented Dec 27, 2025

still relevant -- looking at it now actually

…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
Copy link
Author

lmcrean commented Dec 27, 2025

Ready for review!

Kept --host per @isaacroldan's point about it affecting all extensions, and changed the default to 127.0.0.1 for consistency with shopify theme dev.

Also fixed the lint errors and added a changeset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Make bind address configurable for local servers

4 participants