Back

Getting functions to work on localhost

  • 0
  • Functions
Ernest
17 Mar, 2024, 21:28

I'd like some help on how reach appwrite (api) from a function on my local dev machine. Essentially can anyone help me with the endpoint to use for the SDK Client in my local function? That is for final client = Client().setEndpoint('https://localhost/v1')

I've tried:

  1. My local ip http://192.168.1.11/v1
  2. appwrite service name (from compose) http//:appwrite/v1
  3. Localhost http://localhost/v1 (doesn't work obviously)

But from this message it seems Steven got it to work but I just can't seem to figure it out. This is frustrating because I know I'm missing something simple here.

https://discord.com/channels/564160730845151244/1094376924882685962/1094515291117064263

TL;DR
Developers are trying to reach Appwrite API from a function on their local machine. Initially had issues with connecting to `https://localhost/v1` resulting in "Connection failed." Upgraded to the local IP but faced "Execution timed out." Tried different endpoints without success. Another developer mentioned using `host.docker.internal` as `_APP_DOMAIN_FUNCTIONS`, also questioning how Docker was installed. No specific solution provided in the thread, but it appears the primary issue is correctly defining the endpoint for the SDK Client.
Steven
17 Mar, 2024, 21:40

The local IP should work...maybe use https? What's the error you get?

Also, are you using windows?

Ernest
17 Mar, 2024, 21:44

I'm using Linux. I've tried both http and https.

Ernest
17 Mar, 2024, 21:44

Initially I was getting this error when I was using https://localhost/v1:

TypeScript
AppwriteException: , Connection failed (0) #0      ClientIO.call (package:dart_appwrite/src/client_io.dart:233)
<asynchronous suspension>
#1      Databases.listDocuments (package:dart_appwrite/services/databases.dart:1016)
<asynchronous suspension>
#2      getClassIdIfExists (package:starter_template/main.dart:92)
<asynchronous suspension>
#3      main (package:starter_template/main.dart:44)
<asynchronous suspension>
#4      Future.any.onValue (dart:async/future.dart:615)
<asynchronous suspension>

type 'Null' is not a subtype of type 'int' of 'statusCode'
#0      main (package:starter_template/main.dart)
<asynchronous suspension>
#1      Future.any.onValue (dart:async/future.dart:615)
<asynchronous suspension>

But after updating it to the local ip I'm getting Execution timed out.

Steven
17 Mar, 2024, 21:46

How'd you install docker?

Ernest
17 Mar, 2024, 21:50

Using the docker run command from the docs for v1.4.13

Steven
17 Mar, 2024, 21:50

Docker, not Appwrite

Ernest
17 Mar, 2024, 21:51

I copied the command from appwrite's docs

Ernest
17 Mar, 2024, 21:52

Here's the command, still have it in my history:

TypeScript
docker run -it --rm \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
    --entrypoint="upgrade" \
    appwrite/appwrite:1.4.13
Ernest
17 Mar, 2024, 21:56

Btw what did you mean by host.docker.internal working for you? Did you set that as the _APP_DOMAIN_FUNCTIONS?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more