Callable functions with custom region not working, Unauthenticated error
- 主要言語
- TypeScript
- スター
- 7.8k
- フォーク
- 2.2k
- 平均マージ
- 22時間 28分
- マージ済み PR(30日)
- 6
説明
### 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.
コントリビューションガイド
調査の方向性
callable 関数の定義、app.module.ts、firebase.json、および httpsCallableData を使用している Angular コンポーネントを確認し、設定されている europe-west1 リージョンとデプロイ済みの本番環境を比較します。本番環境への呼び出しを再現し、なぜ Unauthenticated が返されるのかを追跡します。完了条件は、デプロイ済みの V1 callable が Angular アプリケーションからそのエラーなしで動作することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- angular, firebase, typescript
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100