angular / angular/angularfire

Callable functions with custom region not working, Unauthenticated error

Ouverte
#3,409 2 commentaires 2 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
TypeScript
Étoiles
7.8k
Forks
2.2k
Merge moyen
22 h 28 min
PR mergées (30 j)
6

Description

### Version info

**Angular:**
15.2.2

**Firebase:**
9.23.0

**AngularFire:**
7.6.1

### How to reproduce these conditions

**Steps to set up and reproduce**

1. Create angular 15 project
2. Add angularfire
3. Create callable functions with custom region

### Debug output

** Errors in the JavaScript console **

```
main.fc6d01fc3332ae31.js:1 ERROR Error: Uncaught (in promise): Error: FirebaseError: Unauthenticated
Error: FirebaseError: Unauthenticated
```

** Output from `firebase.database().enableLogging(true);` **

How/where do I enable this?

Callable function:

```
import { region } from 'firebase-functions';

export const getInvoicesPerQuarter= region('europe-west1')
.https.onCall(async (data: { id: string; invoiceNumber: string }, context) => {
...
})
```

app.module.ts:

```
provideFunctions(() => {
const functions = getFunctions(getApp(), 'europe-west1');
// const functions = getFunctions();
if (environment.useEmulators) {
connectFunctionsEmulator(functions, 'localhost', 5001);
}
return functions;
}),
```

firebase.json:

```
{
"hosting": [
{
"rewrites": [
{
"source": "/getInvoicesPerQuarter",
"function": "getInvoicesPerQuarter"
}
]
},

```
angular component:

```
import { Functions, httpsCallableData } from '@angular/fire/functions';

const getInvoicesPerQuarterCallable: (data: {
year: number;
quarter: number;
}) => Observable = httpsCallableData<
{ year: number; quarter: number },
string
>(this.functions, 'getInvoicesPerQuarter');

const result = await firstValueFrom(
getInvoicesPerQuarterCallable({ year, quarter }),
);
```

Calling this callable function works in the emulator.
I deploy this to firebase.
I doesn't work on production and I get the Unauthenticated error.
I already contacted firebase support but everything looks fine and they say it's an AngularFire issue and can't help me.
Functions are V1.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Examinez la définition de la fonction callable, app.module.ts, firebase.json et le composant Angular utilisant httpsCallableData, en comparant la région configurée europe-west1 avec la configuration de production déployée. Reproduisez l’appel de production et déterminez pourquoi il renvoie Unauthenticated ; la tâche est terminée lorsque la fonction callable V1 déployée fonctionne depuis l’application Angular sans cette erreur.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, firebase, typescript
Domaine
api, backend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.