I\'m trying to call a callable Cloud Function from my app, but I\'m facing CORS issues.
I can\'t enable Cors since I don\'t have access to the request and response
I had this problem with some of my Firebase functions but not others. I eventually fixed it by doing this:
Without any changes to the function itself, it now runs without any CORS issues.
Probably many will hit this issue with the emulator and cors messages.
I havn't seen my case discussed in any discussion I've seen in Google, I do have seen many "can't reproduce", maybe my case will shade some light:
In my case the issue was that I wasn't running the hosting from the firebase emulator.
When you run your react app via npm start - while the functions run via firebase emulators:start, you will see the Cors errors.
So when testing cloud function calls, rather using npm start, you should do npm run build and then access the app from the emulator...
Search for something like: "hosting: Local server: http://localhost:5000"
few notes -
Your functions should also work against the emulator via
const functions = firebaseApp.functions('europe-west3');// lets assume thats your region
functions.useFunctionsEmulator('http://localhost:5000');
If none of the above is helping: In my case the reason was that I havent correctly set up my regions. This can especially happen when using 3rd party libraries.