firebase init emulators=== Emulators Setup? Which Firebase emulators do you want to set up? Press Space to select emulators, then Enter to confirm your choices. (Press
<space> to select, <a> to toggle all, <i> to invert selection, and <enter> to proceed)❯◯ App Hosting Emulator ◯ Firestore Emulator ◯ Database Emulator ◯ Hosting Emulator ◯ Pub/Sub Emulator ◯ Storage Emulator ◯ Eventarc Emulator(Move up and down to reveal more choices)? Specify your app's root directory relative to your project (./)? The App Hosting emulator uses a file called apphosting.emulator.yaml tooverride values in apphosting.yaml for local testing. This codebase does nothave one, would you like to create it? (Y/n)? Which environment variables would you like to override? (Press <space> toselect, <a> to toggle all, <i> to invert selection, and <enter> to proceed)❯◯ MEMCACHE_ADDR ◯ API_KEY? What new value would you like for plaintext MEMCACHE_ADDR?? What would you like to name the secret reference for API_KEY? (test-api-key)? What new value would you like for secret TESTKEY [input is hidden]? [input is hidden]? Your config has secret values. Please provide a comma-separated list of usersor groups who should have access to secrets for local development:✔ Successfully set IAM bindings on secret test-api-key.
建議使用 Google 群組管理密鑰存取權,而非授予個別使用者存取權。這樣一來,您只要將新成員新增至群組,對方就能存取所需的所有密鑰,簡化開發人員團隊的新成員加入程序。您可能已有適當的群組,供開發人員彼此溝通。透過 Google 網路論壇控管存取權,也有助於確保開發人員離開團隊時,從電子郵件群組中移除後,就無法再存取所有密鑰。如果密鑰可存取實際資料或產生實際副作用,您可能仍應使用 firebase apphosting:secrets:set 輪替金鑰並賦予新值。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-25 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\nYou can perform local tests of your app prior to App Hosting deployment\nusing the App Hosting emulator, which is part of the Firebase Local Emulator\nSuite.\n\nBefore using the App Hosting emulator, make sure that you [understand the\noverall Firebase Local Emulator Suite\nworkflow](/docs/emulator-suite/connect_and_prototype?database=Firestore), and\nthat you [install and configure](/docs/emulator-suite/install_and_configure) the\nLocal Emulator Suite and review its [CLI\ncommands](/docs/emulator-suite/install_and_configure#startup).\n\nThis topic assumes you are already familiar with App Hosting. If needed,\nreview the [App Hosting introduction](/docs/app-hosting) and other materials\nto help you [understand how App Hosting\nworks](/docs/app-hosting/about-app-hosting).\n\nWhat can I do with the App Hosting emulator?\n\nThe App Hosting emulator lets you test and refine your web applications\nlocally. This can streamline your development process and enhance the quality\nof web apps built using Firebase and deployed on App Hosting.\n\nThe App Hosting emulator:\n\n1. Lets you run your web app locally, with environment variables and secrets defined in `apphosting.yaml` configuration files.\n2. Can override environment variables and secrets for use in the emulator with the `apphosting.emulator.yaml` file.\n3. Can be used alongside other Firebase emulators. If you're using the Firestore, Auth, or any other emulator, the Local Emulator Suite ensures that these emulators are started first before the App Hosting emulator.\n\nConfigure the emulator\n\nTo get started, install and initialize the Local Emulator Suite as described\nin [Install, configure and integrate Local Emulator\nSuite](/docs/emulator-suite/install_and_configure). In addition to any other\nFirebase emulators that you want to set up, make sure to select `App Hosting\nEmulator`. The CLI prompts you for some App Hosting emulator values,\nincluding:\n\n- Your app's root directory relative to the project; this is important if you are using [monorepos with App Hosting](/docs/app-hosting/monorepos).\n- Whether you want to override any values for local development.\n- Whether you want to grant teammates access to secrets for local development.\n\n firebase init emulators\n === Emulators Setup\n ? Which Firebase emulators do you want to set up? Press Space to select emulators, then Enter to confirm your choices. (Press\n \u003cspace\u003e to select, \u003ca\u003e to toggle all, \u003ci\u003e to invert selection, and \u003center\u003e to proceed)\n ❯◯ App Hosting Emulator\n ◯ Firestore Emulator\n ◯ Database Emulator\n ◯ Hosting Emulator\n ◯ Pub/Sub Emulator\n ◯ Storage Emulator\n ◯ Eventarc Emulator\n (Move up and down to reveal more choices)\n\n ? Specify your app's root directory relative to your project (./)\n\n ? The App Hosting emulator uses a file called apphosting.emulator.yaml to\n override values in apphosting.yaml for local testing. This codebase does not\n have one, would you like to create it? (Y/n)\n\n ? Which environment variables would you like to override? (Press \u003cspace\u003e to\n select, \u003ca\u003e to toggle all, \u003ci\u003e to invert selection, and \u003center\u003e to proceed)\n ❯◯ MEMCACHE_ADDR\n ◯ API_KEY\n\n ? What new value would you like for plaintext MEMCACHE_ADDR?\n\n ? What would you like to name the secret reference for API_KEY? (test-api-key)\n\n ? What new value would you like for secret TESTKEY [input is hidden]? [input is hidden]\n\n ? Your config has secret values. Please provide a comma-separated list of users\n or groups who should have access to secrets for local development:\n\n ✔ Successfully set IAM bindings on secret test-api-key.\n\nAny values you provide in this setup flow are used to update your\nApp Hosting emulator configuration in `firebase.json`. You can also\nconfigure the App Hosting emulator by updating `firebase.json` directly. The\nschema for the App Hosting emulator is: \n\n {\n ...\n \"emulators\": {\n \"apphosting\": {\n \"startCommand\": \u003ccommand\u003e [optional]\n \"rootDirectory\": \u003cpath\u003e [optional]\n }\n }\n }\n\n- `startCommand` is automatically generated and set when the emulator is initialized. If not provided, the emulator will detect and run your package manager's dev command.\n- `rootDirectory` is used to support monorepo project setups. If your web app is in a subdirectory, you need to provide the path of that directory relative to the root (the location of `firebase.json`).\n\nManage emulation\n\nEmulator initialization creates an `apphosting.emulator.yaml` file in your app's\nroot directory. This configuration file has the same schema as the\n[`apphosting.yaml`](/docs/app-hosting/configure#configure-backend) file used in\nproduction, but instead is meant strictly for local development. By default, the\nemulator reads configuration from your `apphosting.yaml` file, but if an\n`apphosting.emulator.yaml` file is present, then configurations in that file are\nprioritized and given precedence.\n\nThe `apphosting.emulator.yaml` file is designed to be safe to commit and share\nwith colleagues. To help ensure you don't accidentally commit sensitive data to\nsource repositories, any environment variable that is a secret in\n`apphosting.yaml` must also be a secret in `apphosting.emulator.yaml`. If a\nsecret does not need change between production and local development (e.g. a\nGemini API key), it does not need to be added to `apphosting.emulator.yaml`;\ninstead [grant your team access to the secret](#grant-secret-access).\n\nIf your application uses many secrets (for example, API keys for three different\nservices, with different values for each of production, staging, and local\ndevelopment) you may exceed Cloud Secret Manager's free tier and pay $0.06 per\nadditional secret per month. If you prefer to manage local configuration\noutside of source control to avoid this fee, you can use the legacy\n`apphosting.local.yaml` file. Unlike `apphosting.emulator.yaml` this file is\nallowed to provide plaintext values for environment variables that are secret\nvalues in `apphosting.yaml`.\n| **Caution:** The `apphosting.local.yaml` file should not be committed to your source code repository, as the file may contain secret values in plain text.\n\nGrant users or groups access to secrets\n\nSecrets stored in `apphosting.emulator.yaml` are read when the emulator starts\nup. This means that your development team needs access to the secret. You can\nuse the `apphosting:secrets:grantaccess` command to grant access to a secret to\neither a user or a group by email. \n\n firebase apphosting:secrets:grantaccess test-api-key --emails my-team@my-company.com\n\nWhere applicable, consider using test-only keys in `apphosting.emulator.yaml`\nthat don't have access to production data, cannot have global side effects\n(sending emails, charging credit cards), and/or have lower quotas. This helps\nensure that unreviewed code has fewer real-world consequences.\n\nConsider using Google Groups to manage access to secrets rather than granting\naccess to individual users. This will simplify onboarding new members to your\ndeveloper team because adding them to the group will grant them access to all\nthe secrets they need. You may already have an appropriate group where developers\ncommunicate with each other. Controlling access by Google Groups also helps\nensure that developers who leave your team lose access to all secrets when they\nare removed from the email group. If the secret has access to production data\nor real-world side effects, it still may be appropriate to rotate your key and\ngive it a new value with `firebase apphosting:secrets:set` however.\n\nRun the emulator \n\n firebase emulators:start\n\nThis will start all the emulators defined in your `firebase.json` file including\nthe App Hosting emulator."]]