Skip to content

fix: --local arg not working#688

Open
ernestoteo wants to merge 5 commits intomainfrom
587_fix_local
Open

fix: --local arg not working#688
ernestoteo wants to merge 5 commits intomainfrom
587_fix_local

Conversation

@ernestoteo
Copy link
Copy Markdown

@ernestoteo ernestoteo commented May 2, 2025

Closes #587

@ernestoteo
Copy link
Copy Markdown
Author

@kennsippell ,

I have tried to repoduce this error on:

  1. MacOS

versions: Sequoia(15.4.1)
cht-conf: 4.4.1
cht-core: 4.18.0
Instance: localhost
env: export COUCH_URL=http://medic:pwd@localhost:5988/medic
Remark: Everything worked and I didn't get the error described in the ticket.

  1. Ubuntu(22.04.5)

I launched a fresh Ubuntu in VM and installed all necessary libs with CHT Core dev environment setup
versions: Sequoia(15.4.1)
cht-conf: 4.8.0
cht-core: 4.18.0
Instance: localhost
env: export COUCH_URL=http://medic:pwd@localhost:5988/medic
Remark: Everything worked fine and I didn't get the error described in the ticket.

When I use 127.0.0.1 like below
export COUCH_URL=http://medic:pwd@127.0.0.1:5988/medic

I get this error thrown
ERROR --local was specified but COUCH_URL env var is set to '127.0.0.1'. Please use --url for remote servers

And to bypass above error I have updated to ignore 127.0.0.1.

@ernestoteo ernestoteo requested a review from kennsippell May 3, 2025 21:21
@kennsippell
Copy link
Copy Markdown
Member

kennsippell commented May 5, 2025

I just reproduced it

  1. I downloaded the production kenya echis repository at moh-kenya/config-echis-2.0
  2. I upgraded to cht-conf 4.8.0 npm i cht-conf@latest --save-dev
  3. I ran npx cht-conf --local backup-all-forms

Using node v16.20.2 and Manjaro. Does this not fail for you?

INFO Using local url from COUCH_URL environment variable: http://medic:****@localhost:5984/medic 
INFO Checking that http://medic:****@localhost:5988/medic/ is available... 
INFO Processing config in config-echis-2.0. 
INFO Actions:
     - backup-all-forms 
INFO Starting action: backup-all-forms… 
INFO Error: Cookie has domain set to the public suffix "localhost" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.
    at Object.getPublicSuffix (/home/kenn/config-echis-2.0/node_modules/tough-cookie/lib/pubsuffix-psl.js:62:11)
    at permuteDomain (/home/kenn/config-echis-2.0/node_modules/tough-cookie/lib/permuteDomain.js:38:28)
    at MemoryCookieStore.findCookies (/home/kenn/config-echis-2.0/node_modules/tough-cookie/lib/memstore.js:99:21)
    at MemoryCookieStore.findCookies (/home/kenn/config-echis-2.0/node_modules/universalify/index.js:5:67)
    at CookieJar.getCookies (/home/kenn/config-echis-2.0/node_modules/tough-cookie/lib/cookie.js:1410:11)
    at CookieJar.getCookies (/home/kenn/config-echis-2.0/node_modules/universalify/index.js:5:67)
    at CookieJar.getCookieString (/home/kenn/config-echis-2.0/node_modules/tough-cookie/lib/cookie.js:1455:21)
    at CookieJar.getCookieString (/home/kenn/config-echis-2.0/node_modules/universalify/index.js:5:67)
    at node:internal/util:364:7
    at new Promise (<anonymous>) 
ERROR Cookie has domain set to the public suffix "localhost" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.

@ernestoteo ernestoteo requested a review from jkuester June 25, 2025 14:29
@ernestoteo
Copy link
Copy Markdown
Author

I was able to reproduce the error

cht-conf: 5.0.0
cht-core: 4.18.0
Instance: localhost
env: export COUCH_URL=http://medic:pwd@localhost:5988/medic or export COUCH_URL=http://medic:pwd@127.0.0.1:5988/medic
Remark: ERROR Cookie has domain set to the public suffix "localhost" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.

I have added some implementation in order to use 127.0.0.1 even if we export localhost as COUCH_URL like this export COUCH_URL=http://medic:pwd@localhost:5988/medic.

@jkuester , as @kennsippell is off, I would like you to have a look at this and share your opinion and if I am the right path then review it.
Note: I actually pointed the config-echis-2.0 to this repo locally and test and seems to work fine.

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.

Error: Cookie has domain set to the public suffix "localhost" which is a special use domain.

2 participants