Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
Set a location in a Https Callable function on Firebase 9 (stripe customer portal)

I'm trying to set up a button for the user to manage his subscription with Stripe Customer Portal and their Firebase's integration.

Problem, the documentation is valid for the old version of Firebase (8) and I'm using the new one, Firebase 9.

We are on the client side and this is React.js.

This is their js code for calling the function (you can see the complete code here: https://github.com/stripe-samples/firebase-subscription-payments/blob/master/public/javascript/app.js):

const functionLocation = 'us-east1';
    
const functionRef = firebase
      .app()
      .functions(functionLocation)
      .httpsCallable('ext-firestore-stripe-subscriptions-createPortalLink');
    const { data } = await functionRef({ returnUrl: window.location.origin });
    window.location.assign(data.url);
  });

With Firebase 9 it should be something like this:

const functions = getFunctions(firebaseApp)

export async function goToBillingPortal() {
       const functionRef = httpsCallable(functions, 'ext-firestore-stripe-subscriptions-createPortalLink');
    
       const { data } = await functionRef({ returnUrl: window.location.origin });
       window.location.assign(data.url);
 }

The console displays 3 errors:

Access to fetch at 'https://us-central1-xxxxxxxxd76.cloudfunctions.net/ext-firestore-stripe-subscriptions-createPortalLink' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: Redirect is not allowed for a preflight request.

service.ts:206 POST https://us-central1-xxxxxxx76.cloudfunctions.net/ext-firestore-stripe-subscriptions-createPortalLink net::ERR_FAILED

Uncaught (in promise) FirebaseError: internal

Apparently, the problem is that I need to specify the location of the server (ex. us-central1) but I can't understand how to it with Firebase 9. All the guides are for Firebase 8.

I've tried different things like:

const functions = getFunctions(firebaseApp).location("us-central1")

or

const functionRef = httpsCallable(functions, 'ext-firestore-stripe-subscriptions-createPortalLink').location("us-central1")

but it doesn't work.

Ideas?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

As shown here in the doc, you should pass the region as the second parameter of the getFunctions() method:

 const functions = getFunctions(firebaseApp, "europe-west1");
about 4 years ago · Juan Pablo Isaza Report

0

One can also define where to deploy with .region(), which I think even accepts a list:

const CLOUD_FUNCTIONS_REGION = "us-east1";

exports.billing_portal = functions.region( CLOUD_FUNCTIONS_REGION ).https.onCall(
    async (data, context: CallableContext) => {
      
    }
);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!