DEV Community

Discussion on: React & Firebase: Add Firebase to a React App

Collapse
 
farazamiruddin profile image
faraz ahmad

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 * as functions from "firebase-functions";
import * as Cors from "cors";

const cors = Cors({ origin: true });

export const handleCrossOriginRequest = functions.https.onRequest((req, res) => {
  cors(req, res, async () => {
    // your logic here
  });
});

Hope this helps!

Collapse
 
adityamitra profile image
Aditya Mitra • Edited

Yeah, but you need to set the billing method first.
That's painful.

Thread Thread
 
farazamiruddin profile image
faraz ahmad

I see. What do you need cross-origin requests for if I may ask?