I'm a software engineer with a lot of React and startup experience. I write about my opinions on React, using Firebase with React, and lessons from building my 1st startup, Retro.
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.
import*asfunctionsfrom"firebase-functions";import*asCorsfrom"cors";constcors=Cors({origin:true});exportconsthandleCrossOriginRequest=functions.https.onRequest((req,res)=>{cors(req,res,async()=>{// your logic here});});
I'm a software engineer with a lot of React and startup experience. I write about my opinions on React, using Firebase with React, and lessons from building my 1st startup, Retro.
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";
I'm a software engineer with a lot of React and startup experience. I write about my opinions on React, using Firebase with React, and lessons from building my 1st startup, Retro.
I'm a software engineer with a lot of React and startup experience. I write about my opinions on React, using Firebase with React, and lessons from building my 1st startup, Retro.
I'm a software engineer with a lot of React and startup experience. I write about my opinions on React, using Firebase with React, and lessons from building my 1st startup, Retro.
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
corsnpm 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π―