Skip to content

feat(https): add per-function CORS support#106

Merged
kevmoo merged 1 commit intomainfrom
cors_better
Apr 1, 2026
Merged

feat(https): add per-function CORS support#106
kevmoo merged 1 commit intomainfrom
cors_better

Conversation

@kevmoo
Copy link
Copy Markdown
Collaborator

@kevmoo kevmoo commented Apr 1, 2026

  • Update FirebaseFunctionDeclaration and registerFunction to store allowedOrigins
  • Update onRequest, onCall, and onCallWithData to pass CORS options
  • Update server.dart to intercept OPTIONS preflight requests and append headers to responses
  • Add unit tests for origin matching (server_test.dart) and option passing (https_namespace_test.dart)

Fixes #100

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@kevmoo kevmoo changed the base branch from main to cors_header_cleanup April 1, 2026 03:10
@kevmoo kevmoo changed the title cors better feat(https): add per-function CORS support Apr 1, 2026
@kevmoo kevmoo linked an issue Apr 1, 2026 that may be closed by this pull request
@kevmoo kevmoo marked this pull request as draft April 1, 2026 03:50
Base automatically changed from cors_header_cleanup to main April 1, 2026 15:57
- Update `FirebaseFunctionDeclaration` and `registerFunction` to store `allowedOrigins`

- Update `onRequest`, `onCall`, and `onCallWithData` to pass CORS options

- Update `server.dart` to intercept `OPTIONS` preflight requests and append headers to responses

- Add unit tests for origin matching (`server_test.dart`) and option passing (`https_namespace_test.dart`)
@kevmoo kevmoo requested a review from demolaf April 1, 2026 15:58
@kevmoo kevmoo marked this pull request as ready for review April 1, 2026 15:58
// from the Node.js model does not apply here.

// Validate HTTP method for event functions
if (request.method.toUpperCase() == 'OPTIONS' &&
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this fixes the validation order too

Copy link
Copy Markdown
Member

@demolaf demolaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevmoo kevmoo merged commit 22f3500 into main Apr 1, 2026
9 checks passed
@kevmoo kevmoo deleted the cors_better branch April 1, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CORS error when calling a callable function from the JS SDK

2 participants