meteor - Angularfire2: "location.protocol"必须是 http 或 https(一个 Meteor 应用程序)

标签 meteor angular firebase angularfire2 angular2-meteor

我正在使用基于 Meteor v1.4Angular2 rc-5angular2-meteor 制作一个应用。到目前为止一切正常,但我需要将它与我的 Firebase 数据库集成,但出现以下异常(我在 Chrome 上运行该应用程序)。似乎我所有的 typescript 都没有问题,我没有收到任何错误,我的 Meteor 应用程序正常加载,我按照安装和设置教程进行操作,直到第 4 步结束。(但是因为我使用的是 Meteor,所以我没有使用 angular -cli 来创建项目),知道如何解决这个问题吗?谢谢

EXCEPTION: Error: This operation is not supported in the environment this application is running on. 

"location.protocol" must be http or https and web storage must be enabled.

BrowserDomAdapter.logError @ browser_adapter.js:84
BrowserDomAdapter.logGroup @ browser_adapter.js:94
ExceptionHandler.call @ exception_handler.js:65
next @ application_ref.js:348
schedulerFn @ async.js:89
SafeSubscriber.__tryOrUnsub @ Subscriber.js:225
SafeSubscriber.next @ Subscriber.js:174
Subscriber._next @ Subscriber.js:124
Subscriber.next @ Subscriber.js:88
Subject._finalNext @ Subject.js:128
Subject._next @ Subject.js:120
Subject.next @ Subject.js:77
EventEmitter.emit @ async.js:77
onError @ ng_zone.js:124
onHandleError @ ng_zone_impl.js:74
ZoneDelegate.handleError @ zone.js:368
Zone.runTask @ zone.js:297
ZoneTask.invoke @ zone.js:464

最佳答案

您只需要将 location.protocol 设置为 'http' 或 'https'。您可以通过将以下提供程序添加到您的类(class)中来做到这一点。

providers: [{
    provide: WindowLocation, useValue: {
        protocol: 'https' // Change to HTTP if you prefer.
    }
}]

不要忘记通过以下方式导入 WindowLocation:

import {WindowLocation} from "angularfire2";

关于meteor - Angularfire2: "location.protocol"必须是 http 或 https(一个 Meteor 应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39295935/

相关文章:

firebase - Cloud Functions 和 Firebase Functions 之间有什么区别?

javascript - firestore onSnapshot 更新值,但不更新 VueJS 中的 DOM

html - 为什么这种 HTML 和 CSS 组合设置字体颜色和样式失败?

javascript - MeteorJS + Bower 并指定加载顺序

html - Angular 2 *ngFor导致bootstrap 4列内容太瘦

javascript - 在angular2中触发没有eventEmitter的自定义事件

javascript - typescript 错误此条件将始终返回 'true',因为类型没有重叠

javascript - 消防站 : arrays vs sub collection of documents performance

javascript - CollectionsFS 文件未上传到服务器

javascript - Meteor #each - 如何从变量中获取每个单独的项目并将其呈现在页面上?