I've been using Firebase functions emulator to develop the following function and had no issue running it from localhost.
exports.functionName = functions.https.onCall(async (data, context) => {
const var1 = data.var1
const var2 = data.var2
const paymentIntent = await object1.property1.function1({
...
});
return({
clientSecret: paymentIntent.client_secret
})
})
Now that I deployed it on firebase (on the default url of projectName.web.app), when I reach the code which fetches this function, I get the following error:
Access to fetch at 'https://us-central1-projectName.cloudfunctions.net/functionName' from origin 'https://projectName.web.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Why am I getting this error, especially if it's coming from a call made on deployed website hosted by firebase? What can I do to get through this, and will that open me up to any security risks?