Skip to content

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

Adds final touches

Copplee1a519bb27d4
diff --git a/web/docs/guides/functions.mdx b/web/docs/guides/functions.mdx
index 3c254fa0cbd..e232307e63c 100644
--- a/web/docs/guides/functions.mdx
+++ b/web/docs/guides/functions.mdx
@@ -58,15 +58,12 @@ Learn how to develop Edge Functions in less than 7 minutes:
Follow the steps to prepare your Supabase project on your local machine.
-- Install the Supabase CLI. [Installing and Updating Docs](/docs/reference/cli/installing-and-updating).
-- Login to the CLI. [Docs](/docs/reference/cli/supabase-login)
- - Command: `supabase login`
-- Initialize Supabase inside your project. [Docs](/docs/guides/local-development#getting-started)
- - Command: `supabase login`
-- Link to your Remote Project. [Docs](/docs/reference/cli/supabase-link)
- - Command: `supabase link --project-ref your-project-ref`
+- Install the Supabase CLI. [Docs](/docs/reference/cli/installing-and-updating).
+- Login to the CLI using the command: `supabase login`. [Docs](/docs/reference/cli/supabase-login).
+- Initialize Supabase inside your project using the command: `supabase init`. [Docs](/docs/guides/local-development#getting-started).
+- Link to your Remote Project using the command `supabase link --project-ref your-project-ref`. [Docs](/docs/reference/cli/supabase-link).
- Optional
- - Follow [this setup guide](https://deno.land/manual/getting_started/setup_your_environment) to integrate the Deno language server with your editor.
+ - Setup your environment: Follow [this setup guide](https://deno.land/manual/getting_started/setup_your_environment) to integrate the Deno language server with your editor.
## Getting Started
@@ -136,19 +133,25 @@ While serving your local Function, you can execute it using curl:
```bash
curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
- --header 'Authorization: Bearer LOCAL_ANON_KEY' \
+ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs' \
--header 'Content-Type: application/json' \
--data '{ "name":"Functions" }'
```
-- Implementation details
- - All Edge Functions are `POST` requests.
- - The `Authorization` header is required. You can use either the `ANON` key, the `SERVICE_ROLE` key, or a logged-in user's JWT.
- - The Function is proxied through the local API (`http://localhost:54321`)
-
You should see the response `{ "message":"Hello Functions!" }`.
-If you execute Function with a different payload the response will change. Try modifying the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'`.
+<details>
+<summary>Implementation details</summary>
+
+- All Edge Functions are `POST` requests.
+- The `Authorization` header is required. You can use either the `ANON` key, the `SERVICE_ROLE` key, or a logged-in user's JWT.
+- The Function is proxied through the local API (`http://localhost:54321`)
+
+</details>
+<br />
+
+If you execute Function with a different payload the response will change. <br />
+Modify the `--data '{"name":"Functions"}'` line to `--data '{"name":"World"}'` and try invoking the command again!
## Secrets and Environment Variables
@@ -160,7 +163,7 @@ Deno.env.get(MY_SECRET_NAME)
### Default secrets
-By default, Edge Functions have access to several secrets:
+By default, Edge Functions have access to these secrets:
- `SUPABASE_URL`: The API gateway for your Supabase project.
- `SUPABASE_ANON_KEY`: The `anon` key for your Supabase API. This is safe to use in a browser when you have [Row Level Security](/docs/guides/auth/row-level-security) enabled.
@@ -186,30 +189,23 @@ Never check your `.env` files into Git!
Now let's use this function inside our Function. Anywhere in your function, add this line:
```jsx
-console.log(Deno.env.get(MY_NAME))
+console.log(Deno.env.get('MY_NAME'))
```
Now we can invoke our function locally, by serving it with our new `.env.local` file:
```bash
-# Serve the Function with the env file
supabase functions serve hello-world --env-file ./supabase/.env.local
-
-# Invoke the function locally
-curl --request POST 'http://localhost:54321/functions/v1/hello-world' \
- --header 'Authorization: Bearer LOCAL_ANON_KEY' \
- --header 'Content-Type: application/json' \
- --data '{ "name":"Functions" }'
```
-After invoking the function you should see the name “Yoda” output to the terminal.
+When the function starts you should see the name “Yoda” output to the terminal.
### Production secrets
Let's create a `.env` for production. In this case we'll just use the same as our local secrets:
```bash
-cp ./supabase/.env.local ./supabase/.env.
+cp ./supabase/.env.local ./supabase/.env
```
This creates a new file `./supabase/.env` for storing your production secrets.
@@ -220,18 +216,18 @@ Never check your `.env` files into Git!
:::
-Let's push all the secrets from the `.env` file to our remote project using [`secrets set`](/docs/reference/cli/supabase-secrets-set):
+Let's push all the secrets from the `.env` file to our remote project using [`supabase secrets set`](/docs/reference/cli/supabase-secrets-set):
```bash
supabase secrets set --env-file ./supabase/.env
-# You can also set secrets individually using
-# supabase secrets set MY_NAME=Chewbacca
+# You can also set secrets individually using:
+supabase secrets set MY_NAME=Chewbacca
```
-Run the curl again - see the result logged on the dashboard
+You don't need to re-deploy after setting your secrets.
-To see all the secrets which you have set remotely, use [`secrets list`](/docs/reference/cli/supabase-secrets-list):
+To see all the secrets which you have set remotely, use [`supabase secrets list`](/docs/reference/cli/supabase-secrets-list):
```bash
supabase secrets list