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

i18n(zh-cn): update google-firebase.mdx #8550

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/content/docs/zh-cn/guides/backend/google-firebase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,19 @@ const serviceAccount = {
client_x509_cert_url: import.meta.env.FIREBASE_CLIENT_CERT_URL,
};

export const app = activeApps.length === 0 ? initializeApp({
credential: cert(serviceAccount as ServiceAccount),
}) : activeApps[0];
const initApp = () => {
if (import.meta.env.PROD) {
console.info('检测到 PROD 环境变量。使用默认服务账号。')
// 在 Firebase 函数中使用默认配置。Firebase 已将配置注入服务器。
return initializeApp()
}
console.info('从环境变量中加载服务账号。')
return initializeApp({
credential: cert(serviceAccount as ServiceAccount)
})
}

export const app = activeApps.length === 0 ? initApp() : activeApps[0];
```

:::note
Expand Down
Loading