自定义域

为你的生产部署设置自定义域。


默认情况下,你在 EAS Hosting 上的生产部署将如下所示:my-app.expo.app,其中 my-app 是你选择的预览子域名。如果你拥有一个域,你可以将其作为自定义域分配给生产部署。

¥By default, your production deployment on EAS Hosting will look like this: my-app.expo.app , where my-app is your chosen preview subdomain name. If you own a domain, you may assign it as a custom domain to the production deployment.

每个项目只能有一个自定义域,该域分配给生产部署。

¥Each project can have exactly one custom domain, which is assigned to the production deployment.

注意:设置自定义域是一项高级功能,在免费计划中不可用。在 电子防盗系统定价 了解有关不同计划和福利的更多信息。

先决条件

¥Prerequisites

An EAS Hosting project with a production deployment

自定义域将始终加载生产部署。因此,要将自定义域添加到你的项目,你首先需要一个已提升到生产的部署。

¥The custom domain will always load the production deployment. Therefore, to add a custom domain to your project, you will need a deployment that's been promoted to production first.

A domain name

你需要拥有一个要使用的域名。

¥You will need to own a domain name you want to use.

分配自定义域

¥Assigning a custom domain

  1. 在项目的仪表板中,导航到 托管设置

    ¥In your project's dashboard, navigate to Hosting settings.

  2. 如果你没有生产部署,系统将提示你先分配一个。

    ¥If you do not have a production deployment, you'll be prompted to assign one first.

  3. 在自定义域下,输入你要设置的自定义域。支持顶层域和子域。如果你拥有 example.com,则可以选择:

    ¥Under Custom domain, enter the custom domain you'd like to set up. Both apex domains and subdomains are supported. If you own example.com, you can select:

    • example.com:apex 域

      ¥example.com: apex domain

    • anything.example.com:子域

      ¥anything.example.com: a subdomain

  4. 接下来,系统会提示你填写 DNS 提供商的一些 DNS 记录:

    ¥Next, you'll be prompted to fill out some DNS records with your DNS provider:

    • 验证:证明你拥有该域

      ¥Verification: to prove you own the domain

    • SSL:设置 SSL 证书

      ¥SSL: to set up SSL certificates

    • CNAME(子域)或 A 记录(顶点域):将域指向你的生产部署

      ¥CNAME (subdomains) or A record (apex domains): to point the domain at your production deployment

  5. 按下刷新按钮,直到所有检查都通过。根据你的 DNS 提供商,此步骤通常只需几分钟。

    ¥Press the refresh button until all checks pass. Depending on your DNS provider, this step usually only takes a couple of minutes.

如果你要求域名切换为零停机时间,则必须按照表中显示的顺序逐一填写这些记录。也就是说,添加 TXT 记录进行验证,按刷新按钮直到 UI 显示验证成功,然后继续下一个。如果停机时间不重要或不相关,你可以一次添加所有三个 DNS 记录。

¥If you require for the domain name switchover to be zero downtime, it's important to fill out these records one by one in the order they are presented in the table. That is, add the TXT record for verification, press the refresh button until the UI says verification is successful, then proceed to the next one. If downtime isn't important or relevant, you may add all three DNS records at once.

为你的应用分配自定义域后,自定义域将路由到你的生产部署。

¥After assigning a custom domain to your app, the custom domain will route to your production deployment.