【问题标题】:Angularfire2: "location.protocol" must be http or https ( a Meteor app)Angularfire2:“location.protocol”必须是 http 或 https(一个 Meteor 应用程序)
【发布时间】:2017-01-10 18:41:16
【问题描述】:

我正在基于Meteor v1.4Angular2 rc-5 使用angular2-meteor 制作应用程序。到目前为止一切正常,但我需要将它与我的 Firebase 数据库集成,但我得到以下异常(我在 Chrome 上运行该应用程序)。看来我所有的打字稿都很好,我没有收到任何错误,我的 Meteor 应用程序加载正常,我按照安装和设置教程直到第 4 步结束。(但是,由于我使用的是 Meteor,我没有使用角度-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

【问题讨论】:

    标签: meteor angular firebase angularfire2 angular2-meteor


    【解决方案1】:

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

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

    不要忘记通过写来导入WindowLocation:

    import {WindowLocation} from "angularfire2";
    

    【讨论】:

      猜你喜欢
      • 2016-12-21
      • 2016-11-21
      • 2015-08-31
      • 1970-01-01
      • 2020-12-05
      • 2019-11-05
      • 1970-01-01
      • 2022-01-05
      • 2017-12-12
      相关资源
      最近更新 更多