[英]Where should I put "serviceAccountCredentials.json" for Firebase Admin, at production?
in development, I make a config directory and I put the json file in this directory.在开发中,我创建了一个配置目录,并将 json 文件放在该目录中。
>> .env
FIREBASE_ADMINSDK_PATH=./config/firebase-adminsdk-2222222.json
>> test.ts
import { initializeApp, getApps, cert } from 'firebase-admin/app'
const apps = getApps()
if (!apps.length) {
initializeApp({
credential: cert(config.FIREBASE_ADMINSDK_PATH)),
})
}
...
But in production environment, there is only 2 directory in '.output' directory (.output/public, .output/server) So nuxt can not find "./config/firebase-adminsdk-2222222.json" file.但是在生产环境中,'.output'目录中只有2个目录(.output/public,.output/server)所以nuxt找不到“./config/firebase-adminsdk-2222222.json”文件。
Where should I put "serviceAccountCredentials.json" for Firebase Admin, at production?在生产环境中,我应该将 Firebase 管理员的“serviceAccountCredentials.json”放在哪里?
Rather than providing the file location of the service account, you can provide the service account in line as done in this example .无需提供服务帐户的文件位置,您可以像本例中那样在线提供服务帐户。 Reading the
service-account.json
file should give you enough details to fill in the initialization.阅读
service-account.json
文件应该会为您提供足够的详细信息来填写初始化。 Copying the initialization here as well:也在这里复制初始化:
// Providing a service account object inline
admin.initializeApp({
credential: admin.credential.cert({
projectId: "<PROJECT_ID>",
clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
}),
databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
});
NOTE: It is advisable to use attached service accounts when possible and encouraged to use the application default credential in most cases.注意:建议尽可能使用附加服务帐户,并鼓励在大多数情况下使用应用程序默认凭据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.