Skip to content

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

fix db connections for example edge functions (#20889)

Charisa4d4f6879783
diff --git a/examples/edge-functions/supabase/.env.local.example b/examples/edge-functions/supabase/.env.local.example
index a15cee971a7..d3f3566510b 100644
--- a/examples/edge-functions/supabase/.env.local.example
+++ b/examples/edge-functions/supabase/.env.local.example
@@ -11,11 +11,13 @@ IPINFO_TOKEN="your https://ipinfo.io token"
OPENAI_API_KEY="<YOUR API KEY HERE>"
# postgres-on-the-edge & kysely-postgres
+# get your DB params and cert from the project dashboard
+# https://supabase.com/dashboard/project/_/settings/database
+# enable `Use connection pooling` and use `Transaction` mode
DB_HOSTNAME=
DB_PASSWORD=
+DB_USER=
DB_SSL_CERT="-----BEGIN CERTIFICATE-----
-GET YOUR CERT FROM YOUR PROJECT DASHBOARD
-https://supabase.com/dashboard/project/_/settings/database
-----END CERTIFICATE-----"
# puppeteer
diff --git a/examples/edge-functions/supabase/functions/kysely-postgres/index.ts b/examples/edge-functions/supabase/functions/kysely-postgres/index.ts
index 4e91ef1df5b..c0d257dcee9 100644
--- a/examples/edge-functions/supabase/functions/kysely-postgres/index.ts
+++ b/examples/edge-functions/supabase/functions/kysely-postgres/index.ts
@@ -31,8 +31,8 @@ const pool = new Pool(
tls: { caCertificates: [Deno.env.get('DB_SSL_CERT')!] },
database: 'postgres',
hostname: Deno.env.get('DB_HOSTNAME'),
- user: 'postgres',
- port: 5432,
+ user: Deno.env.get('DB_USER'),
+ port: 6543,
password: Deno.env.get('DB_PASSWORD'),
},
1
diff --git a/examples/edge-functions/supabase/functions/postgres-on-the-edge/.env.example b/examples/edge-functions/supabase/functions/postgres-on-the-edge/.env.example
index 638351bc2c8..9cd063de1a6 100644
--- a/examples/edge-functions/supabase/functions/postgres-on-the-edge/.env.example
+++ b/examples/edge-functions/supabase/functions/postgres-on-the-edge/.env.example
@@ -1,2 +1,2 @@
#Use PolyScale connection string with application_name parameter to get code-free database caching
-DATABASE_URL="postgresql:/DB_USERNAME:[email protected]:5432/postgres?application_name=POLYSCALE_CACHE_ID"
\ No newline at end of file
+DATABASE_URL="postgres://postgres.[PROJECT_REF]:[DB_PASSWORD]@psedge.global:5432?application_name=[APPLICATION_NAME]"
diff --git a/examples/edge-functions/supabase/functions/postgres-on-the-edge/index.ts b/examples/edge-functions/supabase/functions/postgres-on-the-edge/index.ts
index e8524f8a329..f8883ce3fb0 100644
--- a/examples/edge-functions/supabase/functions/postgres-on-the-edge/index.ts
+++ b/examples/edge-functions/supabase/functions/postgres-on-the-edge/index.ts
@@ -6,8 +6,8 @@ const pool = new Pool(
tls: { enabled: false },
database: 'postgres',
hostname: Deno.env.get('DB_HOSTNAME'),
- user: 'postgres',
- port: 5432,
+ user: Deno.env.get('DB_USER'),
+ port: 6543,
password: Deno.env.get('DB_PASSWORD'),
},
1