Some trivial fixes to Edge Function guides (#46092)

Was going through user feedback and fixed some of the minor issues with
the guides.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Documentation**
* Added guidance on handling CORS when invoking Edge Functions from the
browser (quickstart and dashboard)
* Updated Deno configuration guidance to reference a top-level deno.json
and adjusted recommended project structure
* Improved internal cross-references for templates and shared
documentation links in functions guides

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46092?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Jeremias Menichelli <jmenichelli@gmail.com>
This commit is contained in:
Lakshan Perera
2026-05-20 05:53:47 +10:00
committed by GitHub
parent 544f4e7195
commit 4363dbb975
5 changed files with 16 additions and 4 deletions

View File

@@ -52,7 +52,7 @@ This approach ensures that when new headers are added to the Supabase SDK, your
#### For versions before 2.95.0
If you're using `@supabase/supabase-js` before v2.95.0, you'll need to hardcode the CORS headers. Add a `cors.ts` file within a [`_shared` folder](/docs/guides/functions/quickstart#organizing-your-edge-functions):
If you're using `@supabase/supabase-js` before v2.95.0, you'll need to hardcode the CORS headers. Add a `cors.ts` file within a [`_shared` folder](/docs/guides/functions/development-environment#recommended-project-structure):
```ts _shared/cors.ts
export const corsHeaders = {

View File

@@ -42,7 +42,7 @@ Set up your editor environment for proper TypeScript support, autocompletion, an
```json
{
"deno.enablePaths": ["./supabase/functions"],
"deno.importMap": "./supabase/functions/import_map.json"
"deno.importMap": "./supabase/functions/deno.json"
}
```
@@ -76,7 +76,7 @@ It's recommended to organize your functions according to the following structure
```bash
└── supabase
├── functions
│ ├── import_map.json # Top-level import map
│ ├── deno.json # Top-level Deno configuration
│ ├── _shared # Shared code (underscore prefix)
│ │ ├── supabaseAdmin.ts # Supabase client with SECRET key
│ │ ├── supabaseClient.ts # Supabase client with PUBLISHABLE key

View File

@@ -116,7 +116,7 @@ Deno.serve(async (req) => {
### 3. Create React Email templates
Create a new folder `_templates` and create a new file `magic-link.tsx` with the following code:
Create a new `_templates` folder following the [recommended project structure](/docs/guides/functions/development-environment#recommended-project-structure) and add a new `magic-link.tsx` file with the following code:
```tsx supabase/functions/send-email/_templates/magic-link.tsx
import {

View File

@@ -151,6 +151,12 @@ There is currently **no version control** for edits! The Dashboard's Edge Functi
Now that your function is deployed, you can invoke it from within your app:
<Admonition type="note" label="Calling an Edge Function from the browser?">
Make sure your function can handle [CORS](/docs/guides/functions/cors) (Cross-Origin Resource Sharing) requests by configuring its headers correctly.
</Admonition>
<Tabs
scrollable
size="small"

View File

@@ -215,6 +215,12 @@ curl --request POST 'https://[YOUR_PROJECT_ID].supabase.co/functions/v1/hello-wo
Now that your function is deployed, you can invoke it from within an app:
<Admonition type="note" label="Calling from the browser?">
Make sure your function can handle [CORS](/docs/guides/functions/cors) (Cross-Origin Resource Sharing) requests by configuring its headers correctly.
</Admonition>
<Tabs
scrollable
size="small"