Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

162
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda