mercredi 5 février 2020

Flutter Web Firebase Auth blocked by CORS policy on Chrome

I have deployed a Flutter web app to my Firebase hosting location. This web app uses firebase_auth.dart from the firebase_auth 0.15.3+1 package.

Authentication and creation of new users from the live Firebase database via email/password works fine on the following platforms:

  • localhost Flutter server launched from VSCode
  • Chrome on Ubuntu desktop
  • Safari on iPad (iOS)
  • Chrome on Pixel 3XL (Android) emulator in Android Studio
  • Firefox on actual Pixel 3XL (Android)
  • Chrome on same Pixel 3XL (Android) in Incognito Mode

But it does not work in Chrome on that same Pixel 3XL (Android) in regular mode. Specifically, I can execute neither FirebaseAuth.instance.signInWithEmailAndPassword() nor FirebaseAuth.instance.createUserWithEmailAndPassword() on this platform alone.

I have tried clearing cache, history, etc. I do not have any additional extensions on Chrome.

I modified my firebase.json file per the example in the similar question here and elsewhere. (I did also create a cors.json file per an answer there, but stopped short of installing it through the Firebase console shell, as it seems to apply to the storage bucket side of Firebase, which I am not using here.)

When examining the Android phone in Remote Debug, I get the following errors and warning:

Error: Access to fetch at 'https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=AIzaSyDgqmPg17-KF8OaaTPyKf-T2LLzQ2fW85U' from origin 'https://[myproject].firebaseapp.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is '' which must be 'true' when the request's credentials mode is 'include'.

Warning: The FetchEvent for "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=[XXXXXkey_redactedXXXXX]" resulted in a network error response: the promise was rejected.

Error: flutter_service_worker.js:1 Uncaught (in promise) TypeError: Failed to fetch

Flutter version: 1.14.6, channel dev, built with 'flutter build web', deployed through firebase CLI.

All other platform configurations with Microsoft, Apple, Linux, or Incognito in the mix work. What do I need to change to get this Google-language web app served from a Google host working on the Google software installed on a Google operating system?




Aucun commentaire:

Enregistrer un commentaire