了解部署 URL 以及如何设置别名。
¥Deployments
部署到 EAS Hosting 是不可变的。每个部署都可以通过由预览子域名和部署 ID 组成的唯一部署 URL 进行访问。
¥Deployments to EAS Hosting are immutable. Each deployment is accessible via a unique deployment URL consisting of the preview subdomain name and the deployment ID.
¥Preview subdomain name
要为项目激活 EAS 托管,你需要选择一个预览子域名。你可以通过 expo.dev 网站上项目的托管部分执行此操作。或者,当你使用 EAS CLI 创建第一个部署时,系统会提示你选择预览子域。
¥To activate EAS Hosting for a project, you'll need to choose a preview subdomain name. You can do this via the Hosting section of your project on the expo.dev website. Alternatively, you'll be prompted to choose a preview subdomain when you create your first deployment using the EAS CLI.
¥Preview and production URLs
预览子域名是用于应用预览 URL 的前缀。例如,如果你选择 my-app
作为预览子域名,你的预览 URL 将是:https://my-app--or1170q9ix.expo.app/
,你的生产 URL 将是:https://my-app.expo.app/
。
¥A preview subdomain name is a prefix used for the preview URL of your app. For example, if you choose my-app
as the preview subdomain name, your preview URL would be: https://my-app--or1170q9ix.expo.app/
, and your production URL would be: https://my-app.expo.app/
.
¥Deployment ID
每个部署都可使用唯一部署 ID 进行识别。此 ID 可以自定义,但默认情况下将是一串随机的字母和数字。
¥Each deployment is identifiable using a unique deployment ID. This ID can be customized but will be a random string of letters and numbers by default.
部署不可变。一旦部署,它们就无法更改,并且始终可以使用其部署 ID 进行访问和识别。
¥Deployments are immutable. Once they are deployed, they cannot be changed and will always remain accessible and identifiable using their deployment ID.
¥Aliases
别名是用于创建部署自定义 URL 的用户定义值。
¥Aliases are user-defined values used for creating custom URLs for deployments.
要进行部署并将其分配给别名,请使用 --alias
选项:
¥To make a deployment and assign it to an alias, use the --alias
option:
-
eas deploy --alias hello
上述命令将创建一个部署,其中 https://my-app--or1170q9ix.expo.app/
具有标准 URL,https://my-app--hello.expo.app/
具有别名。
¥The above command will create a deployment with both a standard URL at https://my-app--or1170q9ix.expo.app/
and an alias at https://my-app--hello.expo.app/
.
每个项目的别名都是唯一的。如果你选择的别名已在使用中,它将被重新分配给新的部署。
¥Aliases are unique per project. If you choose an alias that was already in use, it will get re-assigned to the new deployment.
单个部署可以有多个别名。还可以使用 --id
选项将别名分配给现有部署:
¥A single deployment can have multiple aliases. Aliases can also be assigned to an existing deployment by using the --id
option:
-
eas deploy:alias --id=my-id
在上面的命令中,my-id
是预览 URL 中的 ID。
¥In the above command, the my-id
is the ID in the preview URL.
别名可以有任意名称。例如,如果你想创建一个暂存环境,你可以创建一个名为 staging
的别名并为其分配一个部署。
¥Aliases can have arbitrary names. For example, if you want to create a staging environment, you may create an alias called staging
and assign a deployment to it.
¥Production alias
如果你的预览子域名是 my-app
,则你的生产 URL 将为 https://my-app.expo.app/
。
¥If your preview subdomain name is my-app
, your production URL will be https://my-app.expo.app/
.
与其他别名类似,可以使用 --prod
选项将部署提升到生产:
¥Similar to other aliases, a deployment can be promoted to production using --prod
option:
-
eas deploy --prod
也可以使用其部署 ID 和 --id
选项将现有部署提升到生产环境:
¥Existing deployment can also be promoted to production using its deployment ID with the --id
option:
-
eas deploy:alias --prod --id=deploymentId
¥Terminology
在以下示例中,my-app
被选为预览子域名:
¥In the following example, my-app
is selected as the preview subdomain name:
https://my-app--or1170q9ix.expo.app/
:预览 URL,它是唯一的,并且你的部署可用。
¥https://my-app--or1170q9ix.expo.app/
: Preview URL, which is unique and where your deployment is available.
my-app
:预览子域名。与你的项目绑定的全局唯一前缀。
¥my-app
: Preview subdomain name. Globally unique prefix tied to your project.
or1170q9ix
:部署 ID,此部署独有。
¥or1170q9ix
: Deployment ID, which is unique to this deployment.
https://my-app--hello.expo.app/
:带有别名的部署 URL。
¥https://my-app--hello.expo.app/
: A deployment URL with an alias.
hello
:用户定义的别名。
¥hello
: User-defined alias.
https://my-app.expo.app/
:生产部署 URL。
¥https://my-app.expo.app/
: Production deployment URL.