I have a function that i need to return a list of users after calling an API (firebase function). I am using express CORS on the server to allow requests from local host.
The issue I am having is that the CORS preflight is returning a 204 with no response before my data (which I know is expected for pre flight to fire first) but it (or Fiebase SDK) is throwing an error because 204 was returned with 'no response' so my then function never receives the data. The data is actually received in the 200 response after the CORS response but by then it's too late. The error shown in console is
Error: Response is missing data field.
The code is:
return firebase.functions().httpsCallable('listUsers')().then((users) => {
// pre-flight cors check means this doesnt return users due to the error
console.log(users);
return users;
}).catch(function (error) {
console.error("Error getting document: ", error);
});`
But in network tab I have 204 and 200 with expected result. Anyone experienced this with firebase and cors?