【发布时间】:2021-04-08 22:19:42
【问题描述】:
这可能是微不足道的,但我是 GCP 和应用程序开发的新手。
我有一个与 firebase 集成的 angular-ionic 应用程序(我能够读取和写入 firestore)现在我正在尝试调用 http 触发的云 python 函数。
在我的 firebase 控制台中,我可以看到该功能存在:
Request
https://europe-west6-tmaker-bd14b.cloudfunctions.net/generate_tournament8
我在我的应用程序中调用该函数(目前在本地运行): generateTournament8(eventRefPath:string),实现在以下文件中:
import { AngularFireFunctions } from '@angular/fire/functions';
import { AlertController } from '@ionic/angular';
@Injectable({
providedIn: 'root'
})
export class CloudFunctionsService {
constructor(private firestoreFunctions: AngularFireFunctions, private alertController: AlertController) { }
generateTournament8(eventRefPath:string){
const callable = this.firestoreFunctions.httpsCallable('generate_tournament8');
var res = callable({'event_ref_path': eventRefPath });
res.subscribe(async res => {
const alert = await this.alertController.create({
header: `Time: ${res.date}`,
message: res.msg,
buttons: ['OK']
});
await alert.present();
});
}
}
尝试调用该函数时,我在控制台中收到以下错误:
Access to fetch at 'https://us-central1-tmaker-bd14b.cloudfunctions.net/generate_tournament8' from origin 'http://localhost:8100' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.
我想我错过了一些微不足道的东西。像不正确的权限。你能帮帮我吗?
【问题讨论】:
-
您是否在后端使用 CORS?
标签: javascript angular firebase google-cloud-functions