vercel-deployment
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVercel 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:预检查
- Verify Vercel CLI is installed (). If not:
vercel --versionnpm i -g vercel - Verify authentication: . If not logged in:
vercel whoamivercel login - Determine project name from the current working directory folder name using
basename "$(pwd)"
- 验证Vercel CLI是否已安装()。如果未安装:
vercel --versionnpm i -g vercel - 验证身份状态:。如果未登录:
vercel whoamivercel login - 使用从当前工作目录的文件夹名称确定项目名称
basename "$(pwd)"
Phase 2: Deploy
阶段2:部署
Deploy using the flag to skip interactive prompts. The project name is inferred from the folder name automatically.
--yesPreview deployment (default):
bash
vercel --yesProduction deployment:
bash
vercel --yes --prodThe flag auto-confirms project setup using the folder name as the project name.
--yes使用标志跳过交互式提示进行部署。项目名称会自动从文件夹名称推断。
--yes预览部署(默认):
bash
vercel --yes生产部署:
bash
vercel --yes --prod--yesPhase 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
undefinedSet 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
undefinedbash scripts/deploy.sh /path/to/project prod
undefinedOption B: Manual API call after deploying
选项B:部署后手动调用API
Use the Vercel API to disable on the project:
ssoProtectionbash
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 to the URL.
?teamId=<TEAM_ID>使用Vercel API禁用项目的:
ssoProtectionbash
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:验证
- Confirm deployment URL is accessible without Vercel login
- Print the deployment URL for the user
- 确认部署URL无需Vercel登录即可访问
- 为用户打印部署URL
Environment Variables
环境变量
| Variable | Required | Description |
|---|---|---|
| For auth disable | API token from https://vercel.com/account/tokens |
| For team projects | Team ID from Vercel dashboard |
| 环境变量 | 是否必填 | 说明 |
|---|---|---|
| 用于禁用身份验证时 | 从https://vercel.com/account/tokens获取的API令牌 |
| 适用于团队项目时 | 从Vercel控制台获取的团队ID |
Notes
注意事项
- The flag uses the folder name as the project name by default
--yes - If 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
VERCEL_TOKEN - Setting to
ssoProtectiondisables Vercel Authentication for all deployments (preview and production)null
- 标志默认将文件夹名称作为项目名称
--yes - 如果未设置,部署仍可正常进行,但Vercel身份验证不会被自动禁用。需告知用户可手动在以下路径禁用:Vercel控制台 > 项目 > 设置 > 部署保护 > Vercel身份验证 > 关闭
VERCEL_TOKEN - 将设置为
ssoProtection会禁用所有部署(预览和生产)的Vercel身份验证null