Add --host flag to control server bind address (#1)#3
Merged
Postmodum37 merged 2 commits intoPostmodum37:mainfrom Mar 8, 2026
Merged
Add --host flag to control server bind address (#1)#3Postmodum37 merged 2 commits intoPostmodum37:mainfrom
Postmodum37 merged 2 commits intoPostmodum37:mainfrom
Conversation
* Initial plan * Add --host flag to bind server to custom address (e.g. 0.0.0.0) Co-authored-by: abien <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: abien <[email protected]>
Postmodum37
reviewed
Mar 6, 2026
Owner
Postmodum37
left a comment
There was a problem hiding this comment.
Thanks for the PR — solves a real pain point for WSL2/container users and the implementation is clean. Two issues below.
…value Address PR review feedback: - CORS and displayHost now treat :: (IPv6) as wildcard alongside 0.0.0.0 - --host with no value warns instead of silently falling back to localhost
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.
Problem
When running ocwatch via bunx on WSL2 (Linux), the server binds to IPv6 by default, making it inaccessible from the Windows host browser.
Bun.serve() without an explicit hostname parameter binds to IPv6 on Linux (TCP *:50234 on IPv6), even though the Bun docs (https://bun.sh/docs/api/http) state the default is "0.0.0.0".
There is no way to fix this externally. Unlike port (which supports $BUN_PORT / $PORT env vars), Bun has no environment variable, no bunfig.toml setting, and no CLI flag to control the bind address — the hostname property must be set in code via Bun.serve() options.
Fix
This patch adds a --host
flag (defaulting to localhost) that passes the hostname property to Bun.serve(), giving users explicit control over the bind address. CORS is also adjusted accordingly — --host 0.0.0.0 sets origin: "*" since requests will come from external addresses.Usage: bunx ocwatch --host 0.0.0.0
This is relevant for anyone running ocwatch in WSL2, containers, or remote/headless environments where the default binding is not reachable.