Closed
Description
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
- Create a firebase
onCall
function - Set the function options to use CORS with an array of single item (domain)
- Deploy function
- Make request to function from matching domain in CORS opts
- 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