supabase / functions-relay

API Gateway for Supabase Edge functions
MIT License
35 stars 9 forks source link

Should `DENO_ORIGIN` be the Deno Deploy URL for Self Hosted? #29

Open SteveChurch opened 1 year ago

SteveChurch commented 1 year ago

Improve documentation

I feel as though the documentation around this repo is hugely lacking compared to other Supabase repos.

DENO_ORIGIN - Should this point to the Deno Deploy URL? As this is a relay I assume we are meant to proxy through functions/v1 through to this relay and from here it passes things on to Deno Deploy?

danhtran94 commented 1 year ago

Hi @SteveChurch,

As edge function feature described in this blog, the section mentions below show about how this repo work.

"When a request comes in to an Edge Function you deploy on Supabase, it first lands at a “Relay”. The Relay acts as an API gateway, authenticating the JWT, and providing some additional functionality like logging and rate-limiting. Upon receiving the incoming request, the Relay retrieves the metadata for your Function, and uses it to construct a unique identifier (”Deployment ID”) for the Function. This Deployment ID then gets passed over to the Deno Deploy platform, which takes care of invoking your Function securely, and passing your output back to the Relay, which in turn passes it back to your end-user."

I also skim over this repo and DENO_ORIGIN I think it should point to the Deno Deploy platform.

Further I also figure out how kong proxying to this service in this supabase cli's start config

Docker container used for this service is here https://hub.docker.com/r/supabase/deno-relay

This file contained code to deploy function in eszipContentType format https://github.com/supabase/cli/blob/main/cmd/functions.go https://github.com/supabase/cli/blob/main/internal/functions/deploy/deploy.go

Hope this helps you complete the setup template, love your work :dancers: https://github.com/digitalocean/supabase-on-do/issues/9

danhtran94 commented 1 year ago

On self-hosted version, we can access Edge Functions Panel by direct URL path http://localhost:54323/project/default/functions But it seems broken now. ksnip_20230218-140807

SteveChurch commented 1 year ago

@danhtran94 thanks so much for your take on this, sorry for the delay getting back to you. I won't lie, I lost focus on getting Edge Functions working and I managed to get as much as possible working within database functions. I do however now need 100% an edge function solution but I want this to work as seamlessly as possible with the Supabase CLI.

I get the feeling that a lot more work needs doing around this from the team to ensure it's seamless for self hosting / at least provide better documentation but the information you have provided is really helpful.

I am going to give this another go this weekend as it's the final bit of the puzzle for me. I was debating hosting the Deno functions within a docker container rather than pushing them up to Deno Deploy. This would make more sense to me considering the rest of my infrastructure is based off of https://github.com/digitalocean/supabase-on-do/

Just to note, I did try deploying my Supabase functions straight to Deno, but they don't "just work" and clearly there is some stuff going on which I do not quite understand prior to them making their way up to Deno Deploy.

I am sure 12 months from now the team over at Supabase will have this all nailed down to a tee and a lot easier to get up and running.

A final thought, I might start using DigitalOcean Functions to replace my supabase functions and have them running locally in seperate pm2 processes with a custom relay, but, this would mean that I would have to handle auth etc myself and loose out on this feature of SB.