fix(#790): preserve port from COUCH_URL when using --local#791
fix(#790): preserve port from COUCH_URL when using --local#791inromualdo wants to merge 1 commit intomainfrom
Conversation
The parseLocalUrl function unconditionally overwrote the port to 5988, ignoring any port specified in COUCH_URL. Now the user-specified port is preserved and 5988 is only used as the default fallback.
|
cc: @andrablaj |
jkuester
left a comment
There was a problem hiding this comment.
Thanks for the PR, @inromualdo!
One challenge that we have here is that the current logic of hardcoding the --local port to 5988 is because of how the COUCH_URL envar is used during cht-core development. When you set up your local environment for developing cht-core you need to set the COUCH_URL envar and it needs to point to the port on the host where Couch is listening. This is so that when you run the api server locally (via npm run dev-api) it can connect to your local Couch instance. So, in this case the COUCH_URL value must point to the Couch port (and not to the port that the CHT api server will be listening on).
On the other hand, when cht-conf connects to a --local CHT instance, it needs to use the port the the CHT api server is listening on (either the API_PORT envar or 5988). The --local option leverages the COUCH_URL as a "convenience", but really is trying to connect to a totally different service....
Honestly, I have considered the --local/COUCH_URL functionality to be targeted pretty much at cht-core development. What is your usecase here where you want to leverage --local instead of --url? Perhaps we just need to add the ability to specify a default CHT url to connect to via an envar that is NOT COUCH_URL (e.g. CHT_URL)....
|
Possibly relevant is that you can use |
|
Thanks for the detailed review @jkuester, that makes total sense. To give some context on why I'm using --local instead of --url: I use cht-conf through AI-assisted tools (like Claude Code), and --local lets credentials stay in the environment variable — never passed as a CLI argument. With --url, you have to inline the full URL with credentials, which means they'd flow through the AI. So --local (or an env-var-based alternative) is important for keeping secrets out of the conversation. I hadn't considered that My thinking for the implementation:
This way existing Does that align with what you had in mind? Happy to rework the PR with this approach. |
|
👍 Got it! Very helpful to better understand the usecase here (for use with AI clients). My one thought with the
I do wonder if it is possible to just use creds from an envar along with the cht --url="${CHT_URL}"Would this work with Claude Code? |
--local flag ignores port from COUCH_URL environment variable, always uses 5988
Description
Closes #790
Code review items
License
The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.