Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda