vercel-deployment

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vercel Deployment

Vercel部署

Deploy to Vercel with automatic project naming from the folder name and auto-disable of Vercel Authentication after deployment.
通过自动从文件夹名称生成项目名称,并在部署后自动禁用Vercel身份验证,将项目部署到Vercel。

Workflow

工作流程

Phase 1: Pre-flight Checks

阶段1:预检查

  1. Verify Vercel CLI is installed (
    vercel --version
    ). If not:
    npm i -g vercel
  2. Verify authentication:
    vercel whoami
    . If not logged in:
    vercel login
  3. Determine project name from the current working directory folder name using
    basename "$(pwd)"
  1. 验证Vercel CLI是否已安装(
    vercel --version
    )。如果未安装:
    npm i -g vercel
  2. 验证身份状态:
    vercel whoami
    。如果未登录:
    vercel login
  3. 使用
    basename "$(pwd)"
    当前工作目录的文件夹名称确定项目名称

Phase 2: Deploy

阶段2:部署

Deploy using the
--yes
flag to skip interactive prompts. The project name is inferred from the folder name automatically.
Preview deployment (default):
bash
vercel --yes
Production deployment:
bash
vercel --yes --prod
The
--yes
flag auto-confirms project setup using the folder name as the project name.
使用
--yes
标志跳过交互式提示进行部署。项目名称会自动从文件夹名称推断。
预览部署(默认):
bash
vercel --yes
生产部署:
bash
vercel --yes --prod
--yes
标志会自动确认项目设置,将文件夹名称作为项目名称。

Phase 3: Disable Vercel Authentication

阶段3:禁用Vercel身份验证

After deployment, disable Vercel Authentication (SSO protection) so the deployment is publicly accessible without Vercel login.
部署完成后,禁用Vercel身份验证(SSO保护),使部署内容无需Vercel登录即可公开访问。

Option A: Using the deploy script (preferred)

选项A:使用部署脚本(推荐)

Run the bundled script which handles deployment + auth disable in one step:
bash
undefined
运行捆绑脚本,一键处理部署+身份验证禁用:
bash
undefined

Set token for API access

设置API访问令牌

export VERCEL_TOKEN="<token>"
export VERCEL_TOKEN="<token>"

Optional: set team ID if using a team

可选:如果使用团队项目,设置团队ID

export VERCEL_TEAM_ID="<team-id>"
export VERCEL_TEAM_ID="<team-id>"

Preview deploy

预览部署

bash scripts/deploy.sh /path/to/project
bash scripts/deploy.sh /path/to/project

Production deploy

生产部署

bash scripts/deploy.sh /path/to/project prod
undefined
bash scripts/deploy.sh /path/to/project prod
undefined

Option B: Manual API call after deploying

选项B:部署后手动调用API

Use the Vercel API to disable
ssoProtection
on the project:
bash
PROJECT_NAME=$(basename "$(pwd)")

curl -X PATCH "https://api.vercel.com/v9/projects/$PROJECT_NAME" \
  -H "Authorization: Bearer $VERCEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ssoProtection": null}'
For team projects, append
?teamId=<TEAM_ID>
to the URL.
使用Vercel API禁用项目的
ssoProtection
bash
PROJECT_NAME=$(basename "$(pwd)")

curl -X PATCH "https://api.vercel.com/v9/projects/$PROJECT_NAME" \
  -H "Authorization: Bearer $VERCEL_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"ssoProtection": null}'
对于团队项目,在URL后追加
?teamId=<TEAM_ID>

Option C: Using Vercel CLI curl

选项C:使用Vercel CLI的curl命令

bash
vercel curl -X PATCH "/v9/projects/$(basename "$(pwd)")" \
  -H "Content-Type: application/json" \
  -d '{"ssoProtection": null}'
bash
vercel curl -X PATCH "/v9/projects/$(basename "$(pwd)")" \
  -H "Content-Type: application/json" \
  -d '{"ssoProtection": null}'

Phase 4: Verify

阶段4:验证

  1. Confirm deployment URL is accessible without Vercel login
  2. Print the deployment URL for the user
  1. 确认部署URL无需Vercel登录即可访问
  2. 为用户打印部署URL

Environment Variables

环境变量

VariableRequiredDescription
VERCEL_TOKEN
For auth disableAPI token from https://vercel.com/account/tokens
VERCEL_TEAM_ID
For team projectsTeam ID from Vercel dashboard
环境变量是否必填说明
VERCEL_TOKEN
用于禁用身份验证时https://vercel.com/account/tokens获取的API令牌
VERCEL_TEAM_ID
适用于团队项目时从Vercel控制台获取的团队ID

Notes

注意事项

  • The
    --yes
    flag uses the folder name as the project name by default
  • If
    VERCEL_TOKEN
    is not set, deployment still works but Vercel Authentication won't be auto-disabled. Inform the user they can disable it manually in: Vercel Dashboard > Project > Settings > Deployment Protection > Vercel Authentication > Off
  • Setting
    ssoProtection
    to
    null
    disables Vercel Authentication for all deployments (preview and production)
  • --yes
    标志默认将文件夹名称作为项目名称
  • 如果未设置
    VERCEL_TOKEN
    ,部署仍可正常进行,但Vercel身份验证不会被自动禁用。需告知用户可手动在以下路径禁用:Vercel控制台 > 项目 > 设置 > 部署保护 > Vercel身份验证 > 关闭
  • ssoProtection
    设置为
    null
    会禁用所有部署(预览和生产)的Vercel身份验证