Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single CORS origin ignored for onCall #1563

Closed
bjester opened this issue May 5, 2024 · 2 comments · Fixed by #1564
Closed

Single CORS origin ignored for onCall #1563

bjester opened this issue May 5, 2024 · 2 comments · Fixed by #1564

Comments

@bjester
Copy link
Contributor

bjester commented May 5, 2024

Related issues

This PR #1544 fixed the very same issue for onRequest but not for onCall, both which originated in #1536

[REQUIRED] Version info

node: 18.7.1

firebase-functions: 5.0.1

firebase-tools: 13.8.0

firebase-admin:

[REQUIRED] Test case

const { onCall } = require("firebase-functions/v2/https");

exports.getGreeting = onCall(
 { cors: [/my-project-id\.web\.app$/] },
 (request) => {
   return "Hello, world!";
 }
);

[REQUIRED] Steps to reproduce

  1. Create a firebase onCall function
  2. Set the function options to use CORS with an array of single item (domain)
  3. Deploy function
  4. Make request to function from matching domain in CORS opts
  5. Observe CORS error

[REQUIRED] Expected behavior

CORS options containing an array of a single domain works as expected-- the same as passing the single item unwrapped.

[REQUIRED] Actual behavior

The array of a single CORS option leads it to be ignored, specifically when using onCall and not onRequest as that was fixed.

Access to fetch at 'https://us-central1-my-project-id.cloudfunctions.net/getGreeting' from origin 'https://my-project-id.web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header contains the invalid value 'my-project-id.web.app'. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Were you able to successfully deploy your functions?

Functions deploy fine, but requests are blocked because of CORS

@google-oss-bot
Copy link
Collaborator

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@taeold
Copy link
Contributor

taeold commented Aug 22, 2024

Thank you!

github-merge-queue bot pushed a commit that referenced this issue Aug 26, 2024
… (#1564)

Co-authored-by: Daniel Lee <danielylee@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants