Firebase Callable Function + CORS

后端 未结 9 1251
Happy的楠姐
Happy的楠姐 2020-12-15 04:52

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

9条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 05:27

    For those facing this error after enabling firebase on an existing GCloud project, there is some complexity which is not taken care of automatically as it would be if it were just a firebase app.

    I had this specific problem because I wanted my firebase function to be publicly accessible, but you have to specifically configure this if you're using google's Cloud Functions.

    Here are the steps to fix:

    1. Go to the cloud function tab
    2. Select your cloud function (check box)
    3. Click "Add members" under Permissions tab in the right side
    4. Enter "allUsers"
    5. under "New memebers" Select Role as "Cloud Functions -> "Cloud Functions Invoker"
    6. Save
    7. Test your cloud function by just pasting it in the browser

    Cheers

提交回复
热议问题