相关疑难解决方法(0)

Firebase可调用函数+ CORS

我正在尝试从我的应用中调用可调用的Cloud Function,但是我遇到了CORS问题。 在此处输入图片说明

由于无法访问onCall函数的请求和响应,因此无法启用Cors。这是我的功能:

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))
    })
  })
})
Run Code Online (Sandbox Code Playgroud)

这就是我所说的:

functions.httpsCallable('UserInvitation')({ email: this.input.value }).then((data) => {
      console.log('Sent invitation:', data)
})
Run Code Online (Sandbox Code Playgroud)

Firebase功能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": …
Run Code Online (Sandbox Code Playgroud)

firebase google-cloud-functions

12
推荐指数
8
解决办法
2850
查看次数

标签 统计

firebase ×1

google-cloud-functions ×1