Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(self-host): use `<API_URL>/functions/v1` for Edge Functions

Bobbie Soedirgo8c96d8be272d
diff --git a/docker/.env.example b/docker/.env.example
index 17bb463705f..21304c2557b 100644
--- a/docker/.env.example
+++ b/docker/.env.example
@@ -82,7 +82,8 @@ IMGPROXY_ENABLE_WEBP_DETECTION=true
############
# Functions - Configuration for Functions
############
-FUNCTIONS_HTTP_PORT=9002
+# NOTE: VERIFY_JWT applies to all functions. Per-function VERIFY_JWT is not supported yet.
+FUNCTIONS_VERIFY_JWT=false
############
# Logs - Configuration for Logflare
@@ -101,4 +102,4 @@ VECTOR_API_PORT=9001
# Google Cloud Project details
GOOGLE_PROJECT_ID=GOOGLE_PROJECT_ID
-GOOGLE_PROJECT_NUMBER=GOOGLE_PROJECT_NUMBER
\ No newline at end of file
+GOOGLE_PROJECT_NUMBER=GOOGLE_PROJECT_NUMBER
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 29c790d899d..3e28b3acdc4 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -250,10 +250,9 @@ services:
SUPABASE_URL: http://kong:8000
SUPABASE_ANON_KEY: ${ANON_KEY}
SUPABASE_SERVICE_ROLE_KEY: ${SERVICE_ROLE_KEY}
- SUPABASE_DB_URL: postgresql://postgres:${POSTGRES_PASSWORD}@{POSTGRES_DB}:${POSTGRES_PORT}/${POSTGRES_DB}"
- VERIFY_JWT: "false"
- ports:
- - ${FUNCTIONS_HTTP_PORT}:9000/tcp
+ SUPABASE_DB_URL: postgresql://postgres:${POSTGRES_PASSWORD}@{POSTGRES_DB}:${POSTGRES_PORT}/${POSTGRES_DB}
+ # TODO: Allow configuring VERIFY_JWT per function. This PR might help: https://github.com/supabase/cli/pull/786
+ VERIFY_JWT: "${FUNCTIONS_VERIFY_JWT}"
volumes:
- ./volumes/functions:/home/deno/functions:Z
command:
diff --git a/docker/volumes/api/kong.yml b/docker/volumes/api/kong.yml
index eb1a079eb27..ca90a29a3e4 100644
--- a/docker/volumes/api/kong.yml
+++ b/docker/volumes/api/kong.yml
@@ -153,6 +153,19 @@ services:
- /storage/v1/
plugins:
- name: cors
+
+ ## Edge Functions routes
+ - name: functions-v1
+ _comment: 'Edge Functions: /functions/v1/* -> http://functions:9000/*'
+ url: http://functions:9000/
+ routes:
+ - name: functions-v1-all
+ strip_path: true
+ paths:
+ - /functions/v1/
+ plugins:
+ - name: cors
+
## Analytics routes
- name: analytics-v1
_comment: 'Analytics: /analytics/v1/* -> http://logflare:4000/*'
diff --git a/docker/volumes/functions/hello/index.ts b/docker/volumes/functions/hello/index.ts
new file mode 100644
index 00000000000..f1e20b90e01
--- /dev/null
+++ b/docker/volumes/functions/hello/index.ts
@@ -0,0 +1,16 @@
+// Follow this setup guide to integrate the Deno language server with your editor:
+// https://deno.land/manual/getting_started/setup_your_environment
+// This enables autocomplete, go to definition, etc.
+
+import { serve } from "https://deno.land/[email protected]/http/server.ts"
+
+serve(async () => {
+ return new Response(
+ `"Hello from Edge Functions!"`,
+ { headers: { "Content-Type": "application/json" } },
+ )
+})
+
+// To invoke:
+// curl 'http://localhost:<KONG_HTTP_PORT>/functions/v1/hello' \
+// --header 'Authorization: Bearer <anon/service_role API key>'