Skip to content
Back

How trigger function from outside ?

  • 0
  • Self Hosted
  • Functions
loup
9 Nov, 2024, 17:04

Okay there is the thing. Im using Supabase as main backend, but self host Supabase is a hell and edge functions are just bad. So I wanna use Appwrite functions instead. How can I trigger Appwrite from HTTP Request ? Im using self hosted appwrite and the domain of my appwrite function is quick weird : http://e9e9e9e9e9e9e99e.https//appwrite.mydomain.com Where e9e9e9e9e9e9e99e is the id and https//appwrite.mydomain.com my appwrite domain

TL;DR
Developers are discussing how to generate SSL certificates for their Appwrite functions on a self-hosted domain. It appears that Traefik should automatically generate SSL certificates once the domains are properly set up in the environment variables, but there may be conflicts with Coolify. It's recommended to use separate subdomains for functions and main domains, and to have a wildcard domain to avoid setting up DNS for each function. The developers also encounter various errors related to function executions, which may be caused by incorrect configurations in Coolify. The discussion involves troubleshooting, suggestions of using separate domains, and potential solutions to the errors faced. Additionally, there is a
D5
9 Nov, 2024, 17:17

What if triggering it with rest instead of API?

loup
9 Nov, 2024, 17:19

Ive try :

TypeScript
curl -X POST https://appwrite.mydomain.app/v1/functions/e9e9e9e9e9e9e99e/executions \
-H "Content-Type: application/json" \
-H "X-Appwrite-Project: o3o3o3o3o3oo3o3"

But fonction failed with this :

TypeScript
An internal curl error has occurred within the executor! Error Number: 6. Error Msg: Could not resolve host: 672f985795d76\nError Code: 500
D5
9 Nov, 2024, 17:25

Does the same happen when you trigger it through the console?

loup
9 Nov, 2024, 17:26
D5
9 Nov, 2024, 17:32

Interesting. What's the function code?

loup
9 Nov, 2024, 17:32

Ive take the template starter :

TypeScript
import { Client } from 'node-appwrite';

// This is your Appwrite function
// It's executed each time we get a request
export default async ({ req, res, log, error }) => {
  // Why not try the Appwrite SDK?
  //
  // const client = new Client()
  //    .setEndpoint('https://cloud.appwrite.io/v1')
  //    .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID)
  //    .setKey(process.env.APPWRITE_API_KEY);

  log('req', req);
  log('res', res);

  // You can log messages to the console
  log('Hello, Logs!');

  // If something goes wrong, log an error
  error('Hello, Errors!');

  // The `req` object contains the request data
  if (req.method === 'GET') {
    // Send a response with the res object helpers
    // `res.send()` dispatches a string back to the client
    return res.send('Hello, World!');
  }

  // `res.json()` is a handy helper for sending JSON
  return res.json({
    motto: 'Build like a team of hundreds_',
    learn: 'https://appwrite.io/docs',
    connect: 'https://appwrite.io/discord',
    getInspired: 'https://builtwith.appwrite.io',
  });
};
D5
9 Nov, 2024, 17:35

So the hello world one basically 😅

D5
9 Nov, 2024, 17:35

How do you have installed appwrite 👀

D5
9 Nov, 2024, 17:36

Also, what are the docker logs for the appwrite and openruntimes-executor container?

D5
9 Nov, 2024, 17:36

You can get them with docker compose logs appwrite and docker compose logs openruntimes-executor

D5
9 Nov, 2024, 23:57

I'm not sure about that. You can try to use the same subdomain, but if it doesn't work, create a separated subdomain and that should solve the conflict.

D5
9 Nov, 2024, 23:57

Hmmm why?

D5
9 Nov, 2024, 23:57

From what I understand Coolify acts as a reverse proxy? 🤔

loup
9 Nov, 2024, 23:58

Yes (from what I understand too ahah)

loup
9 Nov, 2024, 23:58

With traefik

D5
9 Nov, 2024, 23:58

If you add it in the env variable, Appwrite's traefik should generate the certificate automatically, but since Coolify could be using it's own traefik, then maybe it's different 👀

loup
10 Nov, 2024, 00:01

Wait maybe I have to leave coolify for Appwrite because there is to many conflict rn

loup
10 Nov, 2024, 00:21

Well Im gonna start using docker compose

loup
10 Nov, 2024, 00:23

Appwrite is supposed to generate the ssl ? Using docker compose my domain appwrite.mydomain.com dont have ssl certificate

D5
10 Nov, 2024, 00:26

Yes, appwrite should generate automatically the SSL certificates

loup
10 Nov, 2024, 00:28

in env we have to set the https prefix ?

TypeScript
//env
_APP_ENV=production
_APP_LOCALE=en
_APP_OPTIONS_ABUSE=enabled
_APP_OPTIONS_FORCE_HTTPS=disabled
_APP_OPTIONS_FUNCTIONS_FORCE_HTTPS=disabled
_APP_OPTIONS_ROUTER_PROTECTION=disabled
_APP_OPENSSL_KEY_V1=iz5AxCPfwGRAbJyb6BNHG9+HolanAb8GdiXCkmueKv0=
_APP_DOMAIN=appwrite.mydomain.com
_APP_DOMAIN_FUNCTIONS=appwrite.mydomain.com
_APP_DOMAIN_TARGET=appwrite.mydomain.com
_APP_CONSOLE_WHITELIST_ROOT=enabled
....
D5
10 Nov, 2024, 00:34

Nope

loup
10 Nov, 2024, 00:53

The doc say :

TypeScript
You need to ensure you have a valid email address set on _APP_SYSTEM_SECURITY_EMAIL_ADDRESS. The default setup comes with certs@appwrite.io as the default value. While this address will work, it's recommended to change it to your own email.

from https://appwrite.io/docs/advanced/self-hosting/tls-certificates But the doc dont say we need _APP_EMAIL_CERTIFICATES to generate certificates

loup
10 Nov, 2024, 01:00

Okay so now Ive set the domain function appwrite-functions.domain.com but how generate ssl for 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