Skip to content

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

chore: update regional invocations guide (#36843)

Lakshan Perera66c6ca89dbea
diff --git a/apps/docs/content/guides/functions/regional-invocation.mdx b/apps/docs/content/guides/functions/regional-invocation.mdx
index 19fef4112b2..6339d78b3bb 100644
--- a/apps/docs/content/guides/functions/regional-invocation.mdx
+++ b/apps/docs/content/guides/functions/regional-invocation.mdx
@@ -12,9 +12,27 @@ However, if your Function performs lots of database or storage operations, invok
- Bulk adding and editing records in your database
- Uploading files
-Supabase provides an option to specify the region when invoking the Function.
+There are couple of ways specify the region when invoking the Function.
-## Using the `x-region` header
+## Use supabase-js client
+
+If you're invoking an Edge Function via supabase-js client, set the region header.
+
+```js name=JavaScript
+// https://supabase.com/docs/reference/javascript/installing
+import { createClient } from '@supabase/supabase-js@2'
+
+// Create a single supabase client for interacting with your database
+const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
+
+// https://supabase.com/docs/reference/javascript/functions-invoke
+const { data, error } = await supabase.functions.invoke('hello-world', {
+ body: { name: 'Functions' },
+ region: 'eu-west-3',
+})
+```
+
+## Set the `x-region` header
Use the `x-region` HTTP header when calling an Edge Function to determine where the Function should be executed:
@@ -29,18 +47,20 @@ curl --request POST 'https://<project_ref>.supabase.co/functions/v1/hello-world'
--data '{ "name":"Functions" }'
```
-```js name=JavaScript
-// https://supabase.com/docs/reference/javascript/installing
-import { createClient } from '@supabase/supabase-js'
+</$CodeTabs>
-// Create a single supabase client for interacting with your database
-const supabase = createClient('https://xyzcompany.supabase.co', 'public-anon-key')
+## Set the `forceFunctionRegion` query parameter
-// https://supabase.com/docs/reference/javascript/functions-invoke
-const { data, error } = await supabase.functions.invoke('hello-world', {
- body: { name: 'Functions' },
- headers: { 'x-region': 'eu-west-3' },
-})
+In case you cannot add the `x-region` header to the request (e.g.: CORS requests, Webhooks), you can use `forceFunctionRegion` query parameter.
+
+<$CodeTabs>
+
+```bash name=cURL
+# https://supabase.com/docs/guides/functions/deploy#invoking-remote-functions
+curl --request POST 'https://<project_ref>.supabase.co/functions/v1/hello-world?forceFunctionRegion=eu-west-3' \
+ --header 'Authorization: Bearer ANON_KEY' \
+ --header 'Content-Type: application/json' \
+ --data '{ "name":"Functions" }'
```
</$CodeTabs>