Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the region configuration for Cloud Functions #659

Closed
3 of 13 tasks
mamillastre opened this issue Jun 28, 2024 · 6 comments · Fixed by #660
Closed
3 of 13 tasks

feat: add the region configuration for Cloud Functions #659

mamillastre opened this issue Jun 28, 2024 · 6 comments · Fixed by #660

Comments

@mamillastre
Copy link
Contributor

mamillastre commented Jun 28, 2024

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Functions
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Current problem

The default region is "us-central1" so if we use an another region, the callByName() method will fail.

Preferred solution

We need a way to change the cloud functions' region. (a callByName() method option or a global configuration ?)

Alternative options

We have a workaround for now by using the callByUrl() method.

const projectId = 'my-project-id';
const region = 'my-region-id';

public async callByName(options: CallByNameOptions): Promise<CallResult> {
    return FirebaseFunctions.callByUrl({
      ...options,
      url: isUsingEmulator ?
        `http://${functionsEmulatorHost}:${functionsEmulatorPort}/${projectId}/${region}/${options.name}` :
        `https://${region}-${projectId}.cloudfunctions.net/${options.name}`
    });
  }

Additional context

Firebase docs: https://firebase.google.com/docs/functions/locations#client-side_location_selection_for_callable_functions

Before submitting

@robingenz
Copy link
Member

@mamillastre I've just created a PR. Would you be willing to test the dev build?

npm i @capacitor-firebase/functions@6.0.0-dev.59ed099.1719590033

@robingenz
Copy link
Member

@mamillastre Have you had a chance to test this?

@mamillastre
Copy link
Contributor Author

I just tested it and it works just as expected on all platforms.
Thanks for the PR.

@robingenz
Copy link
Member

Thank you for testing.

@kbala-ami
Copy link

@robingenz Yes, we need this feature to support CloudFunction 2ndGen. Good if you push as early as posible.

Also, we need to support to connect given database id as well.

Thanks

@robingenz
Copy link
Member

@kbala-ami Feel free to create a feature request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants