【发布时间】:2020-08-21 18:35:10
【问题描述】:
所以我像这样通过 AngularFire 调用 firebase 函数:
const response = await this.aFunctions.httpsCallable<void, ResponseType>('funcName')().toPromise();
这在部署到 firebase(托管)时有效,但在本地环境中(使用 ionic serve),它会抛出此错误:
ERROR Error: Uncaught (in promise): FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8100/firebase-cloud-messaging-push-scope') with script ('http://localhost:8100/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration).
FirebaseError: Messaging: We are unable to register the default service worker. Failed to register a ServiceWorker for scope ('http://localhost:8100/firebase-cloud-messaging-push-scope') with script ('http://localhost:8100/firebase-messaging-sw.js'): A bad HTTP response code (404) was received when fetching the script. (messaging/failed-service-worker-registration).
我在这个项目中没有以任何方式使用 FCM。你知道为什么会发生这种情况吗?
【问题讨论】:
-
该错误看起来与您显示的代码无关。您确定它会影响代码的工作方式吗?
-
它确实在调用任何函数时出现。没关系。我不确定是什么原因造成的,但我很肯定这个项目没有涉及 FCM。 @DougStevenson
-
如果代码正常工作,我会忽略它。
-
问题是它不能正常工作。其他具有类似设置(离子/角度+ firebase)的项目不会给我这个错误,所以我不能忽略它。它仅在部署到 firebase 时才有效。否则调用函数会引发此错误。 @DougStevenson
-
如果您有错误报告,那么我建议您联系 Firebase 支持以寻求帮助。这里没有足够的信息可以使用。 support.google.com/firebase/contact/support
标签: angular firebase ionic-framework google-cloud-functions angularfire