常见问题解答和问题排查
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
本页提供了有关 App Hosting 的常见问题解答 (FAQ)。
App Hosting 常见问题解答
App Hosting 是否支持 Next.js 和 Angular 以外的框架?
App Hosting 为 Next.js 和 Angular 提供预配置的构建和部署支持,我们致力于了解这些框架并解读其原生配置。对于许多
其他框架,开发者社区支持 App Hosting 框架适配器。此外,对于任何具有构建和启动脚本的 Node.js 应用,App Hosting 将尝试构建,但无法可靠地保证成功。请参阅框架集成。
Firebase App Hosting 支持哪些地区?
App Hosting 的适用地区可能会随着时间的推移而扩大。如需了解最新信息,请参阅 App Hosting 位置。
除了 GitHub 之外,我能否使用 GitLab 或其他 Git 提供商进行部署?
目前还不行,但我们已将支持其他提供商纳入 App Hosting 的长期路线图规划。
为什么我在 Firebase 控制台界面中找不到我的代码库?
如果您在 Firebase 控制台中创建新的后端时,您的代码库未显示在选项列表中,请先尝试选择刷新列表。如果首选代码库仍然不可用,您可能需要使用授予对 GitHub 中新代码库的访问权限选项来添加该代码库。
此外,您还可以使用 Firebase App Hosting GitHub 应用管理代码库。为此,请前往您的 GitHub 个人资料,然后依次选择设置和应用。在 Firebase App Hosting 应用的表格行中,点击配置以管理代码库。
为什么我的网站无法在 Android 移动应用 WebView 中正常显示?
在 2025 年第 3 季度之前通过 Firebase 控制台配置了自定义网域的应用可能会发现,该网站在 Android WebView 中无法正常显示。这是因为该时间段内使用的 CNAME 记录与 Android WebView 不兼容。
如需解决此问题,请从 App Hosting 后端移除自定义网域,然后重新添加。更新后的控制台界面将提供 3 条新记录:一条网域的 A 记录和一条 TXT 记录,以及一条 ACME 质询子网域(用于证书)的 CNAME 记录;请使用这些记录来代替之前的 CNAME 记录。
如何更改与我的 App Hosting 项目关联的代码库?
目前,您无法更改代码库。不过,您可以在同一项目中创建与首选代码库关联的新后端,也可以在单独的项目中创建新后端。
标头取决于框架。执行您通常会为框架执行的任何操作。
是否有适用于本地开发且支持 App Hosting 的模拟器?
可以。您可以在 App Hosting 部署之前使用 App Hosting 模拟器(Firebase Local Emulator Suite 的一部分)对应用执行本地测试。请参阅在本地测试应用部署 。
为什么我在 App Hosting 中看到错误,但在 Cloud Build 中没有看到错误?
在这种情况下,您的错误可能来自 Cloud Run。
检查发布的状态以确保。
如何更改或移除关联的 GitHub 账号?
如需移除关联的 GitHub 账号,请打开 Developer Connect,确保已选择您的项目,然后删除 firebase-app-hosting-github-oath
连接和以 apphosting-github-conn-
开头的连接。在 Firebase 控制台中打开 App Hosting 后,您现在应该能够设置新的 GitHub 连接了。
如何为我的 App Hosting 网站设置 Cookie?
虽然在 App Hosting 预览版发布时,该功能尚未推出,但 Set-Cookie
HTTP 响应标头现在可以按预期工作了。
一般 App Hosting 限制和问题排查
- App Hosting 的 CDN 只能在其缓存键中包含一组特定的请求标头。该列表包含 NextJS 的
RSC
、Next-Router-State-Tree
、Next-Router-Prefetch
、Next-Router-Segment-Prefetch
和 Next-Url
标头,以及 Cloud CDN 的标准 Accept
、Accept-Encoding
、Access-Control-Request-Headers
、Access-Control-Request-Method
、Origin
、Sec-Fetch-Dest
、Sec-Fetch-Mode
、Sec-Fetch-Site
、X-Goog-Allowed-Resources
和 X-Origin
。如果响应包含 Vary
标头,但其值未在此处列出,我们的 CDN 将不会缓存该响应。
- 未缓存的静态文件会从 Cloud Run 中提供;在后续版本中,这些文件将存储在 App Hosting 源中并从该源提供,以提高性能。
- Firebase 控制台可能会在创建后端时偶尔显示“找不到 build,build 无效”错误。
- 同一项目中的所有后端共享一个 GitHub 组织/账号。
它们可以连接到相应组织/账号下的不同代码库。
如需创建连接到不同 GitHub 账号的后端,请将它们放在不同的项目中。
Angular 应用限制和问题排查
虽然 App Hosting 对 Angular 的支持正在积极开发和扩展,但仍存在以下限制:
- I18n:虽然核心 I18n 功能可以正常运行,但直接导航到 SSR 页面可能会导致错误。
- 本地化:不支持为不同语言区域构建版本。
- 构建器:目前仅支持应用构建器。
- 环境和 Monorepo 工具:如果 Angular 项目包含多个应用目标,则会失败。如需更完善的 monorepo 支持,请使用 Nx。
Next.js 限制和问题排查
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):2025-08-08。"],[],[],null,["\u003cbr /\u003e\n\nThis page provides answers to frequently asked questions (FAQs) about\nApp Hosting.\n\nApp Hosting FAQ \n\nDoes App Hosting support frameworks other than Next.js and Angular?\n\nApp Hosting provides preconfigured build and deploy support for\nNext.js and Angular, where we've committed to understanding\nthose frameworks and interpreting their native configurations. For a number of\n[other frameworks](/docs/app-hosting/about-app-hosting#other-frameworks), the developer community supports App Hosting\nframework adapters. Additionally, for any Node.js\napplication with a build and start script, App Hosting\nwill attempt builds, but cannot dependably guarantee success. See [Framework\nintegration](/docs/app-hosting/about-app-hosting#frameworks). \n\nWhich regions does Firebase App Hosting support?\n\nThe regions for App Hosting are likely to expand over time. See\n[App Hosting locations](/docs/app-hosting/about-app-hosting#locations)\nfor the most up-to-date information. \n\nCan I use GitLab or other Git providers besides GitHub for deployments?\n\nCurrently you can't, but support for other providers is in the long term\nroadmap for App Hosting. \n\nWhy can't I find my repository in the Firebase console UI?\n\nIf your repository does not appear in the list of options when you\nare creating a new backend in the Firebase console, first try selecting\n**Refresh list** . If the preferred repository is still not\navailable, you may need to add it using the option to **Grant access to\na new repository in GitHub**.\n\nAdditionally, you can manage repositories with the Firebase App Hosting\nGitHub application. To do this, go to your GitHub profile, and select\n**Settings** and then **Applications** . In the table\nrow for the Firebase App Hosting application, click **Configure**\nto manage repositories. \n\nWhy won't my site display normally in Android mobile app WebView?\n\nApps that configured a custom domain with the Firebase console\nprior to Q3 2025 may find that the site does not display properly in Android\nWebView. This occurs because CNAME records used during that period were not\ncompatible with Android WebView.\n\nTo resolve this issue, remove the custom domain from the App Hosting\nbackend and re-add it. The updated console UI will provide 3 new records, an A\nand a TXT record for the domain, and a CNAME for the ACME challenge subdomain\n(for certs); use these records in place of the previous CNAME\nrecord. \n\nHow do I change the repository associated with my App Hosting project?\n\nCurrently, changing the repository isn't possible. However, you can\ncreate a new backend associated with the preferred repository within the same\nproject, or create a new backend in a separate project. \n\nHow can I set headers for my App Hosting site?\n\nHeaders are framework-dependent. Do whatever you would normally do for\nyour framework. \n\nIs there an emulator for local development with App Hosting?\n\nYes, you can perform local tests of your app prior to App Hosting\ndeployment using the App Hosting emulator, which is part of the Firebase\nLocal Emulator Suite. See [Locally test\nyour app deployment](/docs/app-hosting/emulate). \n\nWhy do I see errors in App Hosting but not in Cloud Build?\n\nIn such cases, it's possible that your error may have come from Cloud Run.\nCheck the status of the rollout to be sure. \n\nHow do I change or remove a linked GitHub account?\n\nTo remove the linked GitHub account, open [Developer\nConnect](https://console.cloud.google.com/developer-connect/connections), ensure your project is selected, and delete the\n`firebase-app-hosting-github-oath` connection and the\nconnection that starts with `apphosting-github-conn-`. When\nyou open App Hosting in the Firebase console, you should now be\nable to set up a new GitHub connection. \n\nHow can I set cookies for my App Hosting site?\n\nThough it was not available at the launch of the App Hosting preview, the\n`Set-Cookie` HTTP response header now works as expected.\n\nGeneral App Hosting limitations and troubleshooting\n\n- App Hosting's CDN can only include a specific set of request headers in its cache keys. That list includes NextJS's `RSC`, `Next-Router-State-Tree`, `Next-Router-Prefetch`, `Next-Router-Segment-Prefetch`, and `Next-Url` headers, as well as Cloud CDN's standard `Accept`, `Accept-Encoding`, `Access-Control-Request-Headers`, `Access-Control-Request-Method`, `Origin`, `Sec-Fetch-Dest`, `Sec-Fetch-Mode`, `Sec-Fetch-Site`, `X-Goog-Allowed-Resources`, and `X-Origin`. If a response contains a `Vary` header with a value not listed here, our CDN won't cache it.\n- Uncached static files are served out of Cloud Run; in a later release, they'll be stored and served from the App Hosting origin for better performance.\n- The Firebase console may intermittently show a \"build was not found and is invalid\" error on backend creation.\n- All backends in the same project share a GitHub org/account. They can be connected to different repositories under that org/account. To create backends that are connected to different GitHub accounts, put them in separate projects.\n\nAngular app limitations and troubleshooting\n\nThough App Hosting support for Angular is actively in development and\nexpanding, it has the following limitations:\n\n- **I18n**: While core I18n functionality works, direct navigation to SSR pages can result in errors.\n- **Localization**: Building versions for different locales isn't supported.\n- **Builders**: Only the Application builder is currently supported.\n- **Environments and Monorepo Tooling**: Angular projects that have more than a single application target will fail. For more complete monorepo support, use Nx.\n\nNext.js limitations and troubleshooting\n\n- By default, the [built-in NextJS image optimization](https://nextjs.org/.docs/app/building-your-application/optimizing/images) is disabled on App Hosting unless you explicitly set [`images.unoptimized`](https://nextjs.org/docs/pages/api-reference/components/image#unoptimized) to false or use a custom [Image Loader.](https://nextjs.org/docs/app/api-reference/config/next-config-js/images#example-loader-configuration) See [Optimize image loading on Next.js](/docs/app-hosting/optimize-image-loading).\n- URL paths containing percent-encoded characters are decoded by Cloud Run. This may cause issues with features that expect only encoded URL paths, such as Next.js parallel routing.\n- Currently, App Hosting limits the caching for NextJS apps using [middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware). Over time, cache hit rates should improve.\n- URL paths containing percent-encoded characters are decoded by Cloud Run. This may cause issues with features that expect only encoded URL paths, such as [Next.js parallel routing](https://nextjs.org/docs/app/building-your-application/routing/parallel-routes)"]]