appwrite / sdk-for-cli

[READ-ONLY] Official Appwrite CLI >_
BSD 3-Clause "New" or "Revised" License
85 stars 28 forks source link

🐛 Bug Report: appwrite client command fails with https host #58

Closed maikeriva closed 1 year ago

maikeriva commented 1 year ago

👟 Reproduction steps

When I try to set an https host via the appwrite cli, it fails with the following error:

$ sudo appwrite client --endpoint https://localhost/v1 --verbose --debug --selfSigned true
[sudo] password for sandyseagull: 
endpoint : 
key : 
cookie : 
selfSigned : false
project
projectId : 632ad032e0f1c3f8bb2d
projectName : testProject
Error: Invalid endpoint or your Appwrite server is not running as expected.
    at /usr/local/lib/node_modules/appwrite-cli/lib/commands/generic.js:81:23
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
✗ Error Invalid endpoint or your Appwrite server is not running as expected.

Appwrite itself works normally it is reachable both via the web console and the SDKs. If I replace https with http, the command succeeds. It is very likely not an issue with system permissions as adding sudo to the command does not change the outcome. After a troubleshooting conversation on Discord, I was recommended to open an issue here.

👍 Expected behavior

appwrite client should work as expected with https.

👎 Actual Behavior

appwrite client only works with http.

🎲 Appwrite version

Version 1.0.x

💻 Operating system

Linux

🧱 Your Environment

Appwrite: 1.0.1 appwrite-cli: 1.1.1 OS: Fedora 36

👀 Have you spent some time to check if this issue has been raised before?

🏢 Have you read the Code of Conduct?

stnguyen90 commented 1 year ago

This looks like a bug in the CLI in which the endpoint check ignores the --selfSigned flag:

https://github.com/appwrite/sdk-for-cli/blob/9007d34acecac5359bcc95026703b7ecc4d3d19a/lib/commands/generic.js#L67-L82

As a workaround, I recommend manually updating your ~/.appwrite/prefs.json like:

{
    "endpoint": "https://localhost/v1",
    "selfSigned": true
}