Repository navigation
fix(stack): leave CORS on /functions/v1 to the function (CLI-2923) - #7472
Conversation
The HttpProxy answered every preflight and added Access-Control-Allow-Origin: * to function responses, so a function could not restrict origins. The functions route now passes CORS through to the function, as on the platform. Router errors carry their own CORS headers so browsers can still read them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/ai-review |
CLI benchmark (Lightweight Commands): no changes foundCommit
API calls: unchanged for all 7 commands. Binary size: 134.1 MB, unchanged. Details: timing ranges, API calls per command, slowest phasesTiming ranges
API calls per command
Slowest phasesNo command moved beyond noise, so there are no phase deltas. Comment |
There was a problem hiding this comment.
Superseded by a newer AI review
🤖 AI Review
Confirmed one minor test-coverage gap. No functional defect was verified. Codex reported no findings. Verification used the checked-out source and tests; tests were not run.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟡 MINOR | packages/stack/src/functions/serve.main.ts:212 |
test-coverage |
claude | Tests do not verify the new CORS headers on Functions router errors or the production Functions route's CORS delegation. The new proxy test supplies upstreamCors: true manually, so removing the production flag or router-error headers would escape this coverage. |
Stats
Claude findings: 1 · Codex findings: 0 · Confirmed: 1 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
There was a problem hiding this comment.
🤖 AI Review
Both independent reviews were available. Confirmed Claude's minor test-coverage finding; Codex reported no findings. The CORS implementation and route wiring appear correct, but their integration lacks regression coverage. Runtime tests were not run.
Findings
| Severity | Location | Category | Sources | Claim |
|---|---|---|---|---|
| 🟡 MINOR | packages/stack/src/functions/serve.main.ts:212 |
test-coverage |
claude | Tests do not verify the stack bootstrap's router-error CORS headers or that the real functions shared route delegates CORS upstream. Regressions in either behavior could pass the current tests. |
Stats
Claude findings: 1 · Codex findings: 0 · Confirmed: 1 · Refuted: 0 · Uncertain: 0
Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: manual · Workflow run
This review runs once per PR. A maintainer can request another with a /ai-review comment.
…I-2923) Co-Authored-By: Claude Opus 5.5 <[email protected]>
7ttp
left a comment
There was a problem hiding this comment.
😄 gave this a first pass and tested it end to end alongside supabase/supabase#52709 and supabase/supabase#52710 on self-host and the cors lines up...
tho i've got a couple of super smol (non-blocking) suggestions below:
…es (CLI-2923) Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Solution
HttpRoute.upstreamCors: the proxy skips its CORS headers and preflight shortcut on that route. The proxy's own 502 keeps*./functions/v1shared route sets it.serve.main.ts: router errors (404, 401, worker errors, 500) sendAccess-Control-Allow-Origin: *,Allow-HeadersandExpose-Headers: sb-error-code, matching fix(self-hosted): add CORS headers to Edge Functions router errors 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