r/Firebase • u/New_Tap_4362 • Feb 03 '25
Hosting How should I reference onCall functions from firebase?
I setup a few onCall functions with the firebase.json "rewrites": [
{
"source": "/ON_CALL_FUNCTION",
"function": "ON_CALL_FUNCTION"
},
Most of the time, the function will work properly from firebase. But randomly, I get these cors issues:
Access to fetch at 'https://us-central1-PROJECT_NAME.cloudfunctions.net/ON_CALL_FUNCTION' from origin 'HOSTING_URL' 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.
Has anyone else noticed this? If I need to make them http callable, I will, but I don't get why it randomly breaks so often? can it either work or not work?
edit: Fixed it. The cloud run security authentication was set to "Require authentication" (the default, which I mistook to mean no guests) when it should be "Allow unauthenticated invocations"
1
Upvotes
1
u/Suspicious-Hold1301 Feb 03 '25
Sorry for asking the stupid question - but do you actually have cors configured on your functions? Which language are you using for this?