Skip to content

Single CORS origin ignored for onCall #1563

Closed
@bjester

Description

@bjester

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions