📦 Creating namespace with title "openkounter-COUNTERS" ✨ Success! Add the following to your wrangler.toml: [[kv_namespaces]] binding = "COUNTERS" id = "abc123def..."
将输出的 id 填入 wrangler.toml:
1 2 3 4
[[kv_namespaces]] binding = "COUNTERS" id = "abc123def..."# ← 替换为实际 ID preview_id = "abc123def..."# ← 替换为实际 preview ID(如需要本地开发)
预览环境可选,仅在本地 wrangler dev 时需要:
1
npm run kv:create-preview
4. 部署
1
npm run deploy
5. 本地开发
1
npm run dev
Git 提交与 CI 部署
wrangler.toml 中的 ID 如何处理?
wrangler.toml 中的 KV Namespace ID 不是敏感信息,它只是一个 Cloudflare 资源标识符,没有 API Token 就无法操作 KV 数据,可以安全地提交到 Git。
如果你希望其他开发者也能拉取代码并本地开发,clone 后按上述步骤 3 创建自己的 KV 命名空间并替换 id 即可。