Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularfire2: "location.protocol" must be http or https ( a Meteor app)

I'm making an app with angular2-meteor based on Meteor v1.4 and Angular2 rc-5. so far been alright but I need to integrate it with my Firebase database but I get the exception below (I'm running the app on Chrome). it seems all my typescript is alright and I don't get any errors, my Meteor app loads normally, I followed the tutorial ofInstallation and Setup till end of step 4. (However since I'm using Meteor, I didn't use angular-cli to create the project), any idea how to fix this? thanks

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
like image 847
ePezhman Avatar asked Oct 18 '22 02:10

ePezhman


1 Answers

You just need to set location.protocol to 'http' or 'https'. You can do that by adding the following provider to your class.

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

Don't forget to import WindowLocation by writing :

import {WindowLocation} from "angularfire2";
like image 87
Dev Avatar answered Nov 11 '22 14:11

Dev