appwrite / sdk-for-cli

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

🐛 Bug Report: Error: Invalid URL #139

Closed jack-theripper closed 1 month ago

jack-theripper commented 2 months ago

👟 Reproduction steps

PS C:\Users\User> npm install -g appwrite-cli

added 118 packages in 2s

PS C:\Users\User> appwrite -v

6.0.0

PS C:\Users\User> appwrite login ? Enter your email abc@abc.com ? Enter your password **** ℹ Info: For detailed error pass the --verbose or --report flag ✗ Error: Invalid URL

👍 Expected behavior

....

👎 Actual Behavior

PS C:\Users\User> appwrite login --verbose ? Enter your email abc@abc.com ? Enter your password *** TypeError: Invalid URL at new URL (node:internal/url:775:36) at Client.call (C:\Users\User\AppData\Roaming\npm\node_modules\appwrite-cli\lib\client.js:149:17) at accountCreateEmailPasswordSession (C:\Users\User\AppData\Roaming\npm\node_modules\appwrite-cli\lib\commands\account.js:1016:29) at loginCommand (C:\Users\User\AppData\Roaming\npm\node_modules\appwrite-cli\lib\commands\generic.js:57:15) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'ERR_INVALID_URL', input: '/account/sessions/email' }

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Windows

🧱 Your Environment

No response

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

🏢 Have you read the Code of Conduct?

stnguyen90 commented 2 months ago

@jack-theripper, thanks for creating this issue! 🙏🏼 BTW, version 6.0.0 of the CLI is meant to be used with Appwrite 1.6, but Appwrite Cloud is currently on 1.5. As such, you might run into compatibility problems. It would be best to install version 5.0.5 instead.

Anyways, your endpoint might be wrong. What's the endpoint when you run appwrite client --debug? Since you're using Appwrite Cloud, it should be https://cloud.appwrite.io/v1.

jack-theripper commented 2 months ago

Endpoint is empty. I thought that the CLI should be immediately configured (npm install) for use with Appwrite Cloud. I understood the problem

Thanks for the reply 👍. The issue can be closed

Solved:

appwrite client --endpoint https://cloud.appwrite.io/v1

stnguyen90 commented 2 months ago

Looks like configEndpoint ends up being an empty string here:

https://github.com/appwrite/sdk-for-cli/blob/aa696219ab06b8834d8a54c882050e23c2d62ba3/lib/commands/generic.js#L16

Because globalConfig.getEndpoint() returns an empty string which doesn't trigger the ?? to set it to the default value.