1

I get this error message: Access to fetch at 'https://us-central1-myapp.cloudfunctions.net/myFunction' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

The function looks like this:

exports.myFunction = functions.region("europe-central2").https.onCall((data, context) => {});

There should be a better way than adding members/principals through Google Cloud console.

EDIT: I'm also using the firebase functions framework to call the function.

yzdnegel
  • 103
  • 6
  • You need to use "functions.https.onRequest" instead of "onCall". Using onCall only makes the functions available via firebase cloud function framework and not via network fetch – Dustin Spengler Mar 01 '23 at 00:28
  • @DustinSpengler Yes I found the difference here: https://stackoverflow.com/questions/51066434/firebase-cloud-functions-difference-between-onrequest-and-oncall I'm currently using the firebase functions framework, just wanted to post my solution to the problem. – yzdnegel Mar 01 '23 at 00:32

1 Answers1

1

The solution I used was the first suggestion from here.

You need to specify in which region the function is hosted in the client. I don't believe it's necessary if you have the default "us-central1" server. But in my case I needed to add "europe-central2"

import { getFunctions } from "firebase/functions";
export const fbFunctions = getFunctions(app, "europe-central2");
yzdnegel
  • 103
  • 6