fix(server): respect PLANNOTATOR_SERVER_URL and PLANNOTATOR_HOST env vars#749
Open
buihongduc132 wants to merge 1 commit into
Open
fix(server): respect PLANNOTATOR_SERVER_URL and PLANNOTATOR_HOST env vars#749buihongduc132 wants to merge 1 commit into
buihongduc132 wants to merge 1 commit into
Conversation
…vars
All three servers hardcoded http://localhost:{port} for their server URL.
This broke two real use cases:
1. Running behind a reverse proxy or tunnel (e.g., Cloudflare Tunnel,
ngrok) where the external URL differs from the listen address.
PLANNOTATOR_SERVER_URL lets you override the entire URL.
2. Binding to a specific network interface (e.g., Tailscale IP for
remote access from another machine). PLANNOTATOR_HOST lets you
set just the hostname while keeping the dynamic port.
getServerUrl() priority:
1. PLANNOTATOR_SERVER_URL → full URL override
2. PLANNOTATOR_HOST → hostname override with actual port
3. Default → http://127.0.0.1:{port} (or http://localhost:{port} for remote)
getServerHostname() now also respects PLANNOTATOR_HOST.
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.
What
All three servers hardcoded
http://localhost:{port}for their server URL. No way to override it even though the README documentsPLANNOTATOR_SERVER_URLfor remote access.Why
Two real scenarios where hardcoded localhost doesn't work:
Behind a reverse proxy / tunnel — Cloudflare Tunnel, ngrok, Tailscale Funnel. The external URL is different from the listen address. You need to tell the server what URL to advertise.
Binding to a specific network interface — Tailscale IP, LAN IP, etc. You want the browser to open
http://100.x.x.x:portnothttp://127.0.0.1:port.Changes
packages/server/remote.tsAdded two new exported functions:
getServerUrl(port)— Returns the URL for accessing the server.PLANNOTATOR_SERVER_URL→PLANNOTATOR_HOST→http://127.0.0.1:{port}localhostsince0.0.0.0isn't clickableUpdated
getServerHostname()— Now checksPLANNOTATOR_HOSTbefore falling back to remote/local defaults.packages/server/index.ts,annotate.ts,review.tsReplaced hardcoded ``http://localhost:${port}``` with
getServerUrl(port)in all three servers.Testing
5 new tests covering all priority levels and env var combinations.
Backwards Compatibility
100% — when no env vars are set, behavior is identical to before.