Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastboot, ember simple auth and emberfire dont work each other #606

Open
marendra opened this issue Mar 25, 2020 · 2 comments
Open

fastboot, ember simple auth and emberfire dont work each other #606

marendra opened this issue Mar 25, 2020 · 2 comments

Comments

@marendra
Copy link

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

@kadeempardue
Copy link

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.

@marendra
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants