angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Uncaught Error: "location.protocol" must be http or https when building to device using Ionic 2 & Angular 2

Open redolds opened this issue 10 years ago • 48 comments

Error in question: This operation is not supported in the environment this application is running on. "location.protocol" must be http or https.

This error only occurs when the app is built & running on a device. In the browser it works great (which is logical).

Maybe there's a way to manually set the location.protocol on a cordova app using Ionic 2?

redolds avatar Jun 18 '16 19:06 redolds

I got the same issue with Electron, Ionic 1 and Ionic 2.

LorenzoZaccagnini avatar Aug 15 '16 15:08 LorenzoZaccagnini

Still having issues in Ionic 2.

candelibas avatar Aug 21 '16 23:08 candelibas

Seems like a serious ongoing issue, have been in love with the library as I've been working with it but it's sad that we can't use it in Electron or Ionic 2 style apps.

redolds avatar Aug 22 '16 16:08 redolds

do we have a fix for this yet? thanks!

santiarias avatar Sep 22 '16 23:09 santiarias

anybody to solved this issue?

gollodev avatar Oct 03 '16 03:10 gollodev

@jeffbcross any updates for this issue?

redolds avatar Oct 03 '16 09:10 redolds

Just tested on latest angularfire2, Still it is not posible to use Firebase3 Auth with angularfire2 on ionic 2 Got 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.

using angularfire2@next ([email protected] )

@jeffbcross @davideast should I create new issue or this one could be re-opened?

olostan avatar Oct 03 '16 21:10 olostan

Hi Folks. This is an issue with the Firebase SDK and how it handles location. It's also, to some extent, a limitation as browsers sandbox local (i.e. file://) resources. Thus, handling Ionic's implementation would require an Ionic-specific SDK, or at lest some sort of adapter specifically to address this.

So, long story short: It's complicated and it's not in AngularFire's purview to solve this. With that in mind, I'm locking this thread to prevent further "is this fixed yet" questions.

For quick reference, here are the key discussions from this thread and possible solutions:

@olostan correctly suggests that some of the auth problems can by bypassed by using nraboy/ng2-cordova-auth and then calling signInWithCredential() as shown in this example.

@jlzuarezs correctly points out that one can bypass some of the redirect issues and auth methods by calling the OAuth methods directly as described here

@aaronksaunders suggests aaronksaunders/basicaf2

@harpreet2602 suggests rodrigoreal/ionic2-angularfire-login

katowulf avatar Oct 04 '16 16:10 katowulf