diff --git a/.env.local.example b/.env.local.example index 7ff6b37a..6e495322 100644 --- a/.env.local.example +++ b/.env.local.example @@ -9,8 +9,10 @@ CLOUDFLARE_ACCOUNT_ID= # Leave empty when authenticated locally with `wrangler login`; set it for CI/CD deployments. CLOUDFLARE_API_TOKEN= -# Optional user-scoped API token for configuring Cloudflare Workers Builds. -# Create it at https://dash.cloudflare.com/profile/api-tokens: +# Optional USER API Token for configuring Cloudflare Workers Builds. +# Do NOT use an Account API Token: the Workers Builds Configuration API accepts +# user-scoped tokens only. Create it at https://dash.cloudflare.com/profile/api-tokens +# (My Profile -> API Tokens, not Manage Account -> Account API Tokens): # Create Token -> Create Custom Token -> add Account permissions: # - Workers Builds Configuration: Edit # - Workers Scripts: Read diff --git a/docs/agent-deploy-cloudflare.md b/docs/agent-deploy-cloudflare.md index 04e8fc89..bfad03c7 100644 --- a/docs/agent-deploy-cloudflare.md +++ b/docs/agent-deploy-cloudflare.md @@ -107,7 +107,7 @@ Chinese version: bun run deploy:builds:setup ``` - It reads the fork remote and `.env.local`, then creates or updates the Cloudflare repository connection, production trigger, build commands, cache, watch paths, and build variables. The agent should complete the Cloudflare GitHub App authorization in the browser when available. If Cloudflare requires a build-token choice, use the exact Dashboard path and retry command shown in [Cloudflare Workers Builds](cloudflare-workers-builds.md). + It reads the fork remote and `.env.local`, then creates or updates the Cloudflare repository connection, production trigger, build commands, cache, watch paths, and build variables. The configuration API requires a **User API Token** (`My Profile` -> `API Tokens`), not an Account API Token; set it as `EDGE_EVER_BUILDS_API_TOKEN`. The agent should complete the Cloudflare GitHub App authorization in the browser when available. If Cloudflare requires a build-token choice, use the exact Dashboard path and retry command shown in [Cloudflare Workers Builds](cloudflare-workers-builds.md). Once connected, a GitHub **Sync fork** push automatically migrates and deploys the user's own instance. Do not configure the repository's GitHub Actions Worker deployment for this purpose. diff --git a/docs/cloudflare-workers-builds.md b/docs/cloudflare-workers-builds.md index cc1070ea..fe47a9d1 100644 --- a/docs/cloudflare-workers-builds.md +++ b/docs/cloudflare-workers-builds.md @@ -21,14 +21,14 @@ Cloudflare requires two account-level authorizations that cannot be safely autom 1. Install and authorize the **Cloudflare Workers & Pages** GitHub App for the fork. An Agent can open the Cloudflare dashboard and complete this browser consent; a user only needs to approve the GitHub authorization. 2. Ensure the Worker has a Workers Builds **build token** with permission to deploy Workers and apply D1 migrations. If the setup command reports that it cannot choose a token, open **Worker** -> **Settings** -> **Builds** -> **API token**, create/select the token, then set its UUID as `EDGE_EVER_BUILDS_BUILD_TOKEN_UUID` in `.env.local` and rerun the command. -The setup API call itself needs a user-scoped token with **Workers Builds Configuration: Edit** and **Workers Scripts: Read**. Create it at [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens): +The setup API call requires a **User API Token**, not an **Account API Token**. Workers Builds Configuration API accepts user-scoped tokens only. Create it at [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens) under **My Profile** -> **API Tokens** (not **Manage Account** -> **Account API Tokens**) with **Workers Builds Configuration: Edit** and **Workers Scripts: Read**: 1. Select **Create Token** -> **Create Custom Token**. 2. Under **Account**, add `Workers Builds Configuration: Edit` and `Workers Scripts: Read`. 3. Restrict the token to the Cloudflare account hosting this instance and set a suitable expiry. 4. Create it, then put the value in `.env.local` as `EDGE_EVER_BUILDS_API_TOKEN`. -This token is used only by `bun run deploy:builds:setup` and is never uploaded to the Worker or Cloudflare Builds. You may instead reuse `CLOUDFLARE_API_TOKEN` only if it is a user-scoped token with the same permissions. +This token is used only by `bun run deploy:builds:setup` and is never uploaded to the Worker or Cloudflare Builds. You may instead reuse `CLOUDFLARE_API_TOKEN` only if it is a User API Token with the same permissions. ### Manual fallback diff --git a/docs/cloudflare-workers-builds.zh-CN.md b/docs/cloudflare-workers-builds.zh-CN.md index b0dd5580..a2fc8245 100644 --- a/docs/cloudflare-workers-builds.zh-CN.md +++ b/docs/cloudflare-workers-builds.zh-CN.md @@ -21,7 +21,7 @@ Cloudflare 有两项账号级授权,仓库脚本不能、也不应该绕过: 1. 为 Fork 安装并授权 **Cloudflare Workers & Pages** GitHub App。Agent 可以打开 Cloudflare 页面完成操作,用户只需确认 GitHub 授权。 2. 确保 Worker 已有可部署 Worker 且可执行 D1 migration 的 Workers Builds **build token**。若命令提示无法选择 token,请打开 **Worker** -> **Settings** -> **Builds** -> **API token**,创建/选择该 token,将其 UUID 填入 `.env.local` 的 `EDGE_EVER_BUILDS_BUILD_TOKEN_UUID`,然后重试命令。 -配置 API 本身还需要一个 user-scoped token,具有 **Workers Builds Configuration: Edit** 与 **Workers Scripts: Read** 权限。按以下步骤创建: +配置 API 本身必须使用 **User API Token**,不能使用 **Account API Token**:Workers Builds Configuration API 仅接受 user-scoped token。请在 [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens) 的 **My Profile** -> **API Tokens** 中创建,切勿进入 **Manage Account** -> **Account API Tokens**。它需要 **Workers Builds Configuration: Edit** 与 **Workers Scripts: Read** 权限。按以下步骤创建: 1. 打开 [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens)。 2. 点击 **Create Token** -> **Create Custom Token**。 @@ -29,7 +29,7 @@ Cloudflare 有两项账号级授权,仓库脚本不能、也不应该绕过: 4. 将 token 限制为当前实例所属的 Cloudflare account,并设置合适的过期时间。 5. 创建后把值写入 `.env.local`:`EDGE_EVER_BUILDS_API_TOKEN=`。 -这个 token 仅供 `bun run deploy:builds:setup` 调用,不会上传到 Worker 或 Cloudflare Builds。只有在现有 `CLOUDFLARE_API_TOKEN` 同为 user-scoped 且具备上述权限时,才可直接复用。 +这个 token 仅供 `bun run deploy:builds:setup` 调用,不会上传到 Worker 或 Cloudflare Builds。只有在现有 `CLOUDFLARE_API_TOKEN` 同为 User API Token 且具备上述权限时,才可直接复用。 ### 手动兜底