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 on the onCall function. This is my function:
exports.UserInvitation = functions.https.onCall((data, context) => {
const email = data.email
return new Promise((resolve, reject) => {
admin.auth().createUser({
email: email,
emailVerified: false,
password: password
}).then(resolve).catch((err) => {
console.error(err.code)
reject(new functions.https.HttpsError(err.code, err.message))
})
})
})
And this is how I call it:
functions.httpsCallable('UserInvitation')({ email: this.input.value }).then((data) => {
console.log('Sent invitation:', data)
})
Firebase-functions package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"bluebird": "^3.5.1",
"firebase-admin": "~5.12.0",
"firebase-functions": "^1.0.1"
},
"private": true
}
WEB SDK Firebase version: 4.13.1
throw new functions.https.HttpsError('test/code', 'error message')
it only returns a object with message and status equals to "INTERNAL" – Pietro Coelhotest/code
. It must be one of the standard codes listed here: firebase.google.com/docs/reference/functions/… – bklimt