angular / angular/angularfire

Callable functions with custom region not working, Unauthenticated error

未關閉
#3,409 2 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
7.8k
分支
2.2k
平均合併
22 小時 28 分鐘
30 天內合併 PR
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 function 定義、app.module.ts、firebase.json 以及使用 httpsCallableData 的 Angular 元件,並比較設定的 europe-west1 區域與已部署的 production 環境。重現 production 呼叫並追查其回傳 Unauthenticated 的原因;完成的標準是已部署的 V1 callable 能夠從 Angular 應用程式正常運作,且不再出現該錯誤。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
angular, firebase, typescript
領域
api, backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。