© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4mo ago•
1 reply
Floppy Disk

Edge function cors issue with hono

I have following script in my edge function:
import { Hono } from 'jsr:@hono/hono'
import { cors } from 'jsr:@hono/hono/cors'

const functionName = 'hello-world'
const app = new Hono().basePath(`/${functionName}`)

app.use('*', cors({
  origin: '*',
  allowHeaders: ['authorization', 'x-client-info', 'apikey'],
  allowMethods: ['POST', 'GET', 'OPTIONS', 'PUT', 'DELETE'],
  credentials: true,
}))

app.options('*', (c) => {
  return c.json('ok', 200)
})

app.get('/', (c) => c.text('Hello from edge functions!'))

const org = new Hono()
org.get('/', (c) => c.text('Hello from org route!'))
org.get('/:id/invite', (c) => c.text(`Hello from org invite route with id: ${c.req.param('id')}`))

app.route('/org', org)

Deno.serve(app.fetch)
import { Hono } from 'jsr:@hono/hono'
import { cors } from 'jsr:@hono/hono/cors'

const functionName = 'hello-world'
const app = new Hono().basePath(`/${functionName}`)

app.use('*', cors({
  origin: '*',
  allowHeaders: ['authorization', 'x-client-info', 'apikey'],
  allowMethods: ['POST', 'GET', 'OPTIONS', 'PUT', 'DELETE'],
  credentials: true,
}))

app.options('*', (c) => {
  return c.json('ok', 200)
})

app.get('/', (c) => c.text('Hello from edge functions!'))

const org = new Hono()
org.get('/', (c) => c.text('Hello from org route!'))
org.get('/:id/invite', (c) => c.text(`Hello from org invite route with id: ${c.req.param('id')}`))

app.route('/org', org)

Deno.serve(app.fetch)


And I try to invoke it like:
supabase.functions.invoke('rest/org/1/invite', {
                    body: JSON.stringify({ test: 'data' })
                })
                    .then(console.log)
                    .catch(console.error);
                supabase.functions.invoke('rest', {
                    body: JSON.stringify({ test: 'data' }),
                })
                    .then(console.log)
                    .catch(console.error);
supabase.functions.invoke('rest/org/1/invite', {
                    body: JSON.stringify({ test: 'data' })
                })
                    .then(console.log)
                    .catch(console.error);
                supabase.functions.invoke('rest', {
                    body: JSON.stringify({ test: 'data' }),
                })
                    .then(console.log)
                    .catch(console.error);

But I'm getting Cors errors for some reason.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

edge function issue
SupabaseSSupabase / help-and-questions
6mo ago
Supabase edge function issue
SupabaseSSupabase / help-and-questions
3w ago
Edge function secret issue
SupabaseSSupabase / help-and-questions
3mo ago
InvalidWorkerResponse with Edge Function
SupabaseSSupabase / help-and-questions
3y ago