firebase Cloud Function无法正常工作,并在Angular中给出标头错误

时间:2019-08-30 04:35:21

标签: angular firebase firebase-realtime-database cors google-cloud-functions

  

问题1 =>如果我仅使用functions.pubsub.schedule,则会出现CORS错误。

     

问题2 =>我只需要pubsub.schedule()。不是https.onRequest()

index.ts

import * as functions from "firebase-functions";
import * as admin from "firebase-admin";

const cors = require('cors')({origin: true});
admin.initializeApp();

  export const functions.pubsub.schedule("every day 00:00").onRun(async context => {
      console.log("Okay deploy Done");
      console.log(context);
    })
  

我需要两个函数https和pubsub,但是我收到Header CORS错误,所以我被添加了cors。函数不能像这样工作,但是无论如何我都需要这两个函数。

函数调用

import { AngularFireFunctions } from "@angular/fire/functions";
 constructor(private fun: AngularFireFunctions) {})

 this.fun.httpsCallable("AlienMain")(this.EmailsNotification)
            .pipe(tap(_ => console.log("subscribe to topic")))
            .subscribe(data => {
              console.log(data);
            });

enter image description here

0 个答案:

没有答案