Back

[SOLVED] call api from a function

  • 0
  • Self Hosted
  • Functions
nev-21
13 Jun, 2023, 03:51

yeah it works

TL;DR
The user had an issue calling an API from a function. They were able to solve it by disabling SSL verification using the "httpsAgent" parameter in Axios. They also mentioned trying to call the API using the LAN IP of their machine instead of localhost.
nev-21
13 Jun, 2023, 03:52

I will review cors (maybe that is the error)

Drake
13 Jun, 2023, 03:53

And you said you tried using the LAN IP of your machine?

Drake
13 Jun, 2023, 03:54

And are you disabling the SSL verification?

nev-21
13 Jun, 2023, 03:55

yeah I tried to use the lan ip also

nev-21
13 Jun, 2023, 03:55

no i didn't i will review in axios docs

Drake
13 Jun, 2023, 03:56

Did you test localhost using axios?

nev-21
13 Jun, 2023, 03:57

yeah, but localhost points to the container itself

Drake
13 Jun, 2023, 03:57

And it was https without any extra SSL bypass?

nev-21
13 Jun, 2023, 04:02

yeah

Drake
13 Jun, 2023, 04:06

That's kind of surprising....

What OS do you have?

nev-21
13 Jun, 2023, 04:06

now the error says "self-signed certificate"

nev-21
13 Jun, 2023, 04:06

windows 11 and WSL ubuntu 20.04

Drake
13 Jun, 2023, 04:08

Try to set up ignore SSL verification

Drake
13 Jun, 2023, 04:09

So that API you have...is that running in a docker container?

nev-21
13 Jun, 2023, 04:11

No, the api is running in windows, and I'm trying to call it from an appwrite function (container)

nev-21
13 Jun, 2023, 04:11

sorry i didn't explain it well

nev-21
13 Jun, 2023, 04:14

It is working now, I disabled SSL verification from axios using: httpsAgent: new https.Agent({ rejectUnauthorized: false, }),

nev-21
13 Jun, 2023, 04:14

But It only works with the LAN ip

nev-21
13 Jun, 2023, 04:15

It doesnt work with the bridge 172.17.0.1

Drake
13 Jun, 2023, 04:15

Yes that makes sense because WSL is like a virtual machine inside windows

Drake
13 Jun, 2023, 04:15

That bridge would be a bridge to WSL, not windows

nev-21
13 Jun, 2023, 04:18

Yes, I tried to call the endpoint with curl from WSL, it only works with lan ip not localhost

Drake
13 Jun, 2023, 04:18

[SOLVED] call api from a function

nev-21
13 Jun, 2023, 04:19

Thank you so much @Steven

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