You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit bb34a18
Browse filesBrowse the repository at this point in the historyBrowse files
fix(stack): leave CORS on /functions/v1 to the function (CLI-2923) (#7472)
## Problem
The stack's HttpProxy answers every preflight with 204 and
`Access-Control-Allow-Origin: *`, and adds `*` to function responses
that set no Allow-Origin. A function that restricts origins never sees
the preflight, and its denied responses become readable from any origin.
On the platform, and on self-hosted after supabase/supabase#52709, the
function decides.
Resolves
[CLI-2923](https://linear.app/supabase/issue/CLI-2923/align-experimental-cli-httpproxy-with-self-hosted-gateway-changes).
## Solution
1. `HttpRoute.upstreamCors`: the proxy skips its CORS headers and
preflight shortcut on that route. The proxy's own 502 keeps `*`.
2. The `/functions/v1` shared route sets it.
3. `serve.main.ts`: router errors (404, 401, worker errors, 500) send
`Access-Control-Allow-Origin: *`, `Allow-Headers` and `Expose-Headers:
sb-error-code`, matching supabase/supabase#52710, so browsers can read
them on requests that skip the preflight. A preflight to a missing or
crashing function still fails, since it is not a 2xx.
Functions called from a browser must now handle CORS themselves, as on
the platform. The legacy Kong path is unchanged.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
0 commit comments