emberfire icon indicating copy to clipboard operation
emberfire copied to clipboard

fastboot, ember simple auth and emberfire dont work each other

Open marendra opened this issue 5 years ago • 2 comments

i tried to work with emberfire and embersimple auth, and followed the instruction, and it worked, but when i tried to use fastboot , it failed, it said " Error: The XMLHttpRequest compatibility library was not found.". I tried to use the guide from embersimple auth, by activated the cookie, yes it worked but the session failed to capture the login from firebase probably due i changed the session-stores to follow the guides from ember-simple-auth website, any idea to work around this problem?

thanks

marendra avatar Mar 25 '20 04:03 marendra

Same issue. I gave up using emberfire. Instead I did this workaround.

  1. Installed the package npm install xmlhttprequest --save. It'll likely save 'ember-fetch' in your package.json but xmlhttprequest is a dependency of it.

Added xmlhttprequest to fastbootdependencies in package.json

{
  "dependencies": {
    "xmlhttprequest": "1.8.0"
  },
  "fastbootDependencies": [
    "xmlhttprequest"
  ]
}
  1. Downloaded firebase/app and firebase/auth and imported them in my ember-cli-build.js.
    app.import('vendor/firebase-app.js');
    app.import('vendor/firebase-auth.js');
  1. Added 2 files in an app/instance-initializers folder
  • The first was firebase.js file to initialize firebase.
export function initialize(applicationInstance) {
  if (firebase.apps.length === 0) {
    var firebaseConfig = {
       ...
    }

    firebase.initializeApp(firebaseConfig);
  }
}

export default {
  initialize
};

  • The second was a xmlhttprequest.js file to require the library in Fastboot
export function initialize(applicationInstance) {
  if (typeof FastBoot !== 'undefined') {
    window.XMLHttpRequest = FastBoot.require('xmlhttprequest').XMLHttpRequest;
  }
}

export default {
  initialize
};

  1. Added firebase as a global to my .eslintrc.js file so I don't get any errors compiling.
  globals: {
    firebase: "readonly"
  },

Done. I was able to console.log(firebase.auth()) from my Ember Service without the XMLHttpRequest error and I saw the output in both my terminal and the browser.

kadeempardue avatar Apr 25 '20 03:04 kadeempardue

many thanks, can we use the firebase that you just initialize to work on firestore?

marendra avatar Apr 28 '20 10:04 marendra