• 简体中文
  • 部署

    GitPigeon 是单租户的:每人为自己的博客部署一份。各平台共用同一份核心代码,只需换入口。

    前置准备

    1. 一个 GitHub 仓库(用来存评论,可以和你博客仓库分开)
    2. 一个 Fine-grained PAT(见 GitHub 配置)
    3. 一个 Cloudflare Turnstile Site Key / Secret Key
    4. 一个发件方式:Resend 或 MailPort(见 邮件配置)

    Vercel

    1. 导入本仓库
    2. 在 Project Settings → Environment Variables 填入 环境变量
    3. Framework Preset 选 Other,Build Command 留空,Output Directory 留空
    4. 部署完成后访问 /api/health 自检

    Netlify

    1. 导入本仓库
    2. netlify.toml 已配置好 publish = "public" 与 functions 目录
    3. 在 Site settings → Environment variables 填入变量
    4. 部署后访问 /api/health

    Cloudflare Workers

    1. 执行 npm run build 生成 public/embed.js 与 public/review.js
    2. 用 wrangler deploy 部署,wrangler.toml 已声明静态资源目录
    3. 用 wrangler secret put 逐项写入敏感变量
    4. 访问 https://<worker>.workers.dev/api/health

    Cloudflare Pages

    functions/api/[[path]].ts 已把 /api/* 转发到共享路由,public/_routes.json 限定只有 /api/* 走函数,其余走静态资源。

    1. 在 Cloudflare Dashboard → Workers & Pages → Create → Pages,连接本仓库
    2. Build command 填 npm run build,Build output directory 填 public
    3. 在 Settings → Environment variables 填入 环境变量
    4. 部署后访问 https://<project>.pages.dev/api/health

    注意事项:

    • Pages 的环境变量在改动后需要重新部署才生效
    • 若你的博客也在 Pages 上,注意本系统的 /api/* 与博客自身的 worker 路由不要冲突
    • Pages 免费版函数有每日请求上限,作为评论系统通常足够

    本地运行(不推荐用于生产)

    本地方式适合调试与内网自用,不推荐作为生产部署:缺少 TLS、没有边缘缓存、进程需要常驻,且与平台 Git 集成无关。

    1. 执行 npm run build
    2. 复制 .env.example 为 .env 并填写
    3. 执行 npm run serve:local
    npm run build
    npm run serve:local

    脚本会打包 dev-server.mjs 并用 Node 内置 HTTP 服务启动,默认端口 8787,可用 PORT 覆盖:

    PORT=9000 npm run serve:local

    本地模式使用 Node 的 Web Request / Response 适配层,行为与边缘平台一致,但不具备平台级缓存与鉴权能力。生产请使用上文的 Vercel / Netlify / Workers / Pages。

    部署后自检

    访问 /api/health,确认:

    • status 为 ok
    • git.readable 为 true(PAT 能读到评论仓库)
    • mail.configured 为 true(若开启了审核)
    • sameRepoWarning 为 null(若你选择不同仓库)