Note: With the release of v9 of the firebase library, this post is out of date.
I've been using React together with Firebase for several...
For further actions, you may consider blocking this person and/or reporting abuse
I really like firebase. It would be great if they would allow us to perform cross-origin API requests in firebase functions.
I like it too! You can do cross-origin requests. You just need to use the
cors
npm package.Here's an example I pulled from a function I wrote.
Hope this helps!
Yeah, but you need to set the billing method first.
That's painful.
I see. What do you need cross-origin requests for if I may ask?
I applied this and Firebase logged a warning to console immediately. It suggests that you should only import the part you use. So, for this example:
Rather than this >> import firebase from "firebase";
It suggests to use this >> import firebase from "firebase/app";
Thanks for the heads up! I updated the example.
That is not working in v. 9.0.1. So to make it work, use this:
On the first step, do
import { initializeApp } from 'firebase/app'; - instead of importing just 'firebase' as a default import
And to check is the app initialized, do
import { getApps } from 'firebase/app'; - instead of importing just 'firebase'
const firebaseApp = getApps()[0]; - instead of firebase.apps[0]
The rest remain the same.
Thank you! The API has changed a lot with the new release. Planning on making an update soon.
Cool article!
I wrote a post that teaches authentication with firebase on the backend
dev.to/betiol/how-to-handle-authen...
awesome! I was going to post something very similar next :)
Nice one ๐๐ฝ
I did it but there is an error:
TypeError: Cannot read property 'options' of undefined
Very nice and usable post๐ฏ