Angularfire: SSR mode: 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

Created on 10 Aug 2020  路  13Comments  路  Source: angular/angularfire

Version info

Angular: 9.1

Firebase: 7.13.2

AngularFire: 6.0.0

Other (e.g. Ionic/Cordova, Node, browser, operating system): The error happens when running ng run <project>:serve-ssr on local OS (Mac or Windows) However it seems that auth still works. So maybe this should be a warning and not an error? We can still login and everything works fine.

How to reproduce these conditions

Run Angular in SSR mode (using Nest)

Steps to set up and reproduce

I'm not really sure how to reproduce this. I believe it started appearing in our logs when we first implemented AngularFireAuth.

Debug output

* Errors in the JavaScript console *

** Angular Universal Live Development Server is listening on http://localhost:4200, open your browser on http://localhost:4200 **
Auth Failed [u [Error]: This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.] {
  code: 'auth/operation-not-supported-in-this-environment',
  a: null
}

* Output from firebase.database().enableLogging(true); *

No output shown.

Expected behavior

Not to see the error in the log.

Actual behavior

Error in log. But nothing seems to be broken. Should this be a warning instead?

Most helpful comment

After updating from 6.0.2 to 6.0.3 I am no longer able to open my Ionic/Capacitor app on iOS and get the same error. I had to roll back to 6.0.2 for it to work again.

Screen Shot 2020-09-25 at 9 20 45 AM

All 13 comments

Can you try with 6.0.3? I should be guarding against using auth in SSR now.

After updating from 6.0.2 to 6.0.3 I am no longer able to open my Ionic/Capacitor app on iOS and get the same error. I had to roll back to 6.0.2 for it to work again.

Screen Shot 2020-09-25 at 9 20 45 AM

I do encounter the exact same issue after upgraded to 6.0.3.

@jamesdaniels Same for me - My Ionic/Capacitor app fails to load with the same error after using 6.0.3 (actually 6.0.3-canary.77a9a15 since I was trying to get the Analytics issue fixed). Loaded fine in 6.0.2. Hard to say what happened in 6.0.3 that's causing this.

Amazingly, if I set server.iosScheme in capacitor.config.json to chrome-extension, the app loads perfectly fine.

@jamesdaniels Same for me - My Ionic/Capacitor app fails to load with the same error after using 6.0.3 (actually 6.0.3-canary.77a9a15 since I was trying to get the Analytics issue fixed). Loaded fine in 6.0.2. Hard to say what happened in 6.0.3 that's causing this.

Amazingly, if I set server.iosScheme in capacitor.config.json to chrome-extension, the app loads perfectly fine.

Setting the iosScheme to chrome-extension fixed the problem for me too but this destroys saved data from local storage ... is there no other solution? I have the problem with 6.0.0+ too. But version 5.4.2 works!

Confirmed happening for me after updating from 6.0.0 + . Testing to see if rolling back to 6.0.0 or so fixes it.

Silent updating with ^ in package json can be a curse sometimes and this unfortunately bypassed my testing and I submitted a broken app to the app store :(

OK, can confirm upgrading to 6.0.3 breaks my authentication with this error. 6.0.2 is the last stable one for me. I double checked after removing node_modules, package-lock.json and doing a fresh install. The break only happens on iOS and I am running an ionic5/ cordova application. Curiously, I don't get the error on some iOS devices.

Getting the error in an Electron/Cordova hybrid application after upgrading.

For me, the error comes from the AngularFireAuth.user observable use. Removing it removes the error.

(PS : in case it's not clear, this is not a solution, this is a complain, I need to get the currently logged in user !)

(PS 2 : switching back to 6.0.2 resolves the issue)

Ah! I think I know what this is, I added an await for getRedirectResult to reduce thrashing on the observable, which is probably unsupported outside of the browser. I have a work around in mind. I'll address in a patch soon.

Cut 6.0.4-canary.9a26fbe which has a possible fix, hopefully it's sufficient. Please give it a try and LMK. If it works I'll cut 6.0.4 ASAP.

@jamesdaniels I can confirm that the issue has been resolved with 6.0.4-canary.9a26fbe and Firebase v8 馃憤

@jamesdaniels I can confirm that the issue has been resolved with 6.0.4-canary.9a26fbe and Firebase v8 馃憤

Thank you, I was not able to test it out :(

Thanks for confirming, I don't have an Ionic app handy to test in. Will cut 6.0.4 final later today.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

StephenFluin picture StephenFluin  路  3Comments

adriandurran picture adriandurran  路  3Comments

sharomet picture sharomet  路  3Comments

KLiFF2606 picture KLiFF2606  路  3Comments

mypark picture mypark  路  3Comments