The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Updated README and examples
Lakshan Perera4b59e8ba58c6
diff --git a/apps/reference/docs/guides/functions/examples.mdx b/apps/reference/docs/guides/functions/examples.mdxindex 4c4940ba8b8..be88249f54f 100644--- a/apps/reference/docs/guides/functions/examples.mdx+++ b/apps/reference/docs/guides/functions/examples.mdx@@ -41,7 +41,11 @@ const examples = [description: 'Generate Open Graph images with Deno and Supabase Edge Functions, no framework needed.',href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/opengraph',},-+ {+ name: 'Get User Location',+ description: 'Get user location data from user's IP address',+ href: 'https://github.com/supabase/supabase/tree/master/examples/edge-functions/supabase/functions/location',+ },]You can find a list of useful [Edge Function Examples](https://github.com/supabase/supabase/tree/master/examples/edge-functions) in our GitHub repository.diff --git a/examples/edge-functions/supabase/functions/location/README.md b/examples/edge-functions/supabase/functions/location/README.mdnew file mode 100644index 00000000000..b2c0bacceb7--- /dev/null+++ b/examples/edge-functions/supabase/functions/location/README.md@@ -0,0 +1,11 @@+# Get User Location++This example shows how you can get user location based on the IP provided in X-Forwarded-For header in a request.++You will need to signup for an account in https://ipinfo.io and provide it as `IPINFO_TOKEN` environment variable ([learn how to set environment variables to your functions](https://supabase.com/docs/guides/functions#secrets-and-environment-variables)).++## Deploy++```bash+supabase functions deploy location --no-verify-jwt+```diff --git a/examples/edge-functions/supabase/functions/location/index.ts b/examples/edge-functions/supabase/functions/location/index.tsindex 438a33418a2..c9df62475af 100644--- a/examples/edge-functions/supabase/functions/location/index.ts+++ b/examples/edge-functions/supabase/functions/location/index.ts@@ -10,7 +10,7 @@ function ips(req: Request) {serve(async (req) => {const clientIps = ips(req) || [''];- const res = await fetch(`https://ipinfo.io/${clientIps[0]}?token=XXXX`, {+ const res = await fetch(`https://ipinfo.io/${clientIps[0]}?token=${Deno.env.get('IPINFO_TOKEN')}`, {headers: { 'Content-Type': 'application/json'}});const { city, country } = await res.json();