vercel

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Vercel Deployment Guide

Vercel 部署指南

Deployment Protection and Agent Access

部署保护与Agent访问

Vercel deployments may have Deployment Protection enabled, which requires authentication to access preview deployments. This can block automated testing and agent access to preview URLs.
Vercel部署可能已启用Deployment Protection,这会要求用户进行身份验证才能访问预览部署。这可能会阻止自动化测试和Agent访问预览URL。

Identifying Protected Deployments

识别受保护的部署

If you encounter a login page or authentication requirement when accessing a Vercel preview URL, the deployment has protection enabled. Signs include:
  • Redirect to
    vercel.com/login
    or SSO login page
  • 401/403 errors when accessing the deployment
  • Preview URLs that require Vercel team membership
如果访问Vercel预览URL时遇到登录页面或身份验证要求,则说明该部署已启用保护。迹象包括:
  • 重定向至
    vercel.com/login
    或SSO登录页面
  • 访问部署时出现401/403错误
  • 要求具备Vercel团队成员身份的预览URL

Enabling Agent Access with Protection Bypass

通过保护绕过功能启用Agent访问

To allow agents and automated systems to access protected deployments, users need to set up Protection Bypass for Automation:
  1. Navigate to Project Settings
    • Go to the Vercel Dashboard
    • Select the project
    • Click on SettingsDeployment Protection
  2. Generate a Protection Bypass Secret
    • Under "Protection Bypass for Automation", click Generate Secret
    • Copy the generated secret securely
  3. Using the Bypass Secret
    The secret can be used in two ways:
    As a Header:
    bash
    curl -H "x-vercel-protection-bypass: <secret>" https://your-preview-url.vercel.app
    As a Query Parameter:
    https://your-preview-url.vercel.app?x-vercel-protection-bypass=<secret>
  4. For Browser-Based Testing
    • Append
      ?x-vercel-protection-bypass=<secret>
      to the preview URL
    • The secret will be stored in a cookie for subsequent requests
要允许Agent和自动化系统访问受保护的部署,用户需要设置Protection Bypass for Automation
  1. 导航至项目设置
    • 进入Vercel控制台
    • 选择对应的项目
    • 点击设置部署保护
  2. 生成保护绕过密钥
    • 在"Protection Bypass for Automation"下,点击Generate Secret
    • 安全地复制生成的密钥
  3. 使用绕过密钥
    密钥有两种使用方式:
    作为请求头:
    bash
    curl -H "x-vercel-protection-bypass: <secret>" https://your-preview-url.vercel.app
    作为查询参数:
    https://your-preview-url.vercel.app?x-vercel-protection-bypass=<secret>
  4. 基于浏览器的测试
    • 追加
      ?x-vercel-protection-bypass=<secret>
      到预览URL末尾
    • 密钥将存储在Cookie中,用于后续请求

Alternative: Disable Protection for Previews

替代方案:禁用预览部署的保护

If protection bypass is not suitable, users can disable protection for preview deployments:
  1. Go to SettingsDeployment Protection
  2. Set "Vercel Authentication" to Only Production Deployments or Disabled
<IMPORTANT> If you cannot access a Vercel preview deployment due to authentication requirements, inform the user that they need to either: 1. Set up a Protection Bypass secret and provide it to you, OR 2. Disable Deployment Protection for preview deployments in their Vercel project settings
Do NOT repeatedly attempt to access protected URLs without the bypass secret. </IMPORTANT>
如果保护绕过功能不适用,用户可以禁用预览部署的保护:
  1. 进入设置部署保护
  2. 将"Vercel Authentication"设置为仅生产部署已禁用
<IMPORTANT> 如果因身份验证要求无法访问Vercel预览部署,请告知用户他们需要执行以下操作之一: 1. 设置Protection Bypass密钥并提供给你,或者 2. 在其Vercel项目设置中禁用预览部署的Deployment Protection
请勿在没有绕过密钥的情况下反复尝试访问受保护的URL。 </IMPORTANT>

Environment Variables

环境变量

Set environment variables in Vercel Dashboard under SettingsEnvironment Variables, or use the Vercel CLI:
bash
vercel env add MY_SECRET
Access in your application:
typescript
const secret = process.env.MY_SECRET;
在Vercel控制台的设置环境变量中设置环境变量,或使用Vercel CLI:
bash
vercel env add MY_SECRET
在应用中访问:
typescript
const secret = process.env.MY_SECRET;

Vercel CLI Commands

Vercel CLI 命令

Common Vercel CLI commands:
bash
undefined
常用的Vercel CLI命令:
bash
undefined

Login to Vercel

登录Vercel

vercel login
vercel login

Deploy to preview

部署到预览环境

vercel
vercel

Deploy to production

部署到生产环境

vercel --prod
vercel --prod

List deployments

列出所有部署

vercel ls
vercel ls

View deployment logs

查看部署日志

vercel logs <deployment-url>
vercel logs <deployment-url>

Pull environment variables locally

拉取环境变量到本地

vercel env pull
undefined
vercel env pull
undefined