feat: explicit cors config shape ('default' | 'disabled' | { headers })#102
Merged
Conversation
Keeps boolean/Record forms accepted but deprecated.
commit: |
mandarini
marked this pull request as ready for review
July 10, 2026 12:16
Reads more clearly as an on/off switch and matches the SDK-1149 proposal. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
kallebysantos
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the
withSupabasecorsoption an explicit shape ('default' | 'disabled' | { headers }) instead of the ambiguousboolean | Record<string, string>. The old forms remain accepted but are deprecated, so this is non-breaking. Addresses SDK-1149 from the API review report.What kind of change does this PR introduce?
Feature (API cleanup), plus docs and tests. Non-breaking.
What is the current behavior?
corsacceptsboolean | Record<string, string>:true(default) applies the standard supabase-js CORS headersfalsedisables CORS handlingRecord<string, string>sets custom headersThis mixes a boolean sentinel with a bare header hash under one field, which is hard to type, document, and evolve.
What is the new behavior?
corsnow accepts an explicit shape:'default'applies the standard supabase-js CORS headers (still the default)'disabled'disables CORS handling{ headers }sets custom headersThe old
booleanand bareRecord<string, string>forms are still accepted but marked@deprecatedin the JSDoc, following the same pattern as the existingallowtoauthdeprecation. They can be removed in a future major.Changes:
src/cors.ts: widen the internalCorsConfigunion, add an exportedisCorsDisabled()predicate, and teachbuildCorsHeadersto read the{ headers }shape (distinguished from a bare record via an'headers' in configcheck).src/with-supabase.ts: replace the three inlinecors !== falsechecks withisCorsDisabled(config.cors).src/types.ts: update the publiccorsfield to the new union with deprecation tags, set@defaultValueto'default', and refresh the JSDoc and inline example.cors.test.tsandwith-supabase.test.tswith coverage for'default','disabled', and{ headers }, plus a dedicatedisCorsDisabledsuite. Existing deprecated-form tests are kept.README.mdanddocs/getting-started.mdto lead with the new shape and note the deprecated forms.Additional context
CORS is only handled by the root
@supabase/serverexport. All four adapters (Hono, H3, Elysia, NestJS) already doOmit<WithSupabaseConfig, 'cors'>and delegate CORS to their framework, so the widened union flows through unchanged and no adapter edits were needed.Verification:
npm run typecheck,npm run lint, andnpm test(196 tests) all pass. Backward compatibility confirmed:cors: falseand bare-record configs still compile (with a deprecation hint) and behave as before.