diff --git a/README.md b/README.md index 5559af0..688251e 100644 --- a/README.md +++ b/README.md @@ -105,12 +105,17 @@ WmailHub/ ## 生产部署(Cloudflare Workers) -1. `bunx wrangler d1 create wmailhub` → 将 `database_id` 填入 `console/wrangler.jsonc` +线上实例:**https://wmailhub.adx9.com**(Worker `wmailhub-console`,自定义域名由 wrangler `routes.custom_domain` 自动建 DNS + 签证书)。 + +1. `bunx wrangler d1 create wmailhub` → 将 `database_id` 填入 `console/wrangler.jsonc`(线上:`cfc47e65-c71e-470f-96db-5bc23e3e31a4`) 2. `bunx wrangler r2 bucket create wmailhub` -3. 依次执行 `bunx wrangler d1 execute wmailhub --remote --file=./migrations/0001_init.sql`、`0002_accounts_webhooks.sql`、`0003_mail_link_v2.sql` +3. 依次执行 `bunx wrangler d1 execute wmailhub --remote --file=./migrations/0001_init.sql` … `0004_single_key_markdown.sql`(0001~0004 按序号全部执行,0004 依赖 0001 的 api_credentials) 4. `cd console && bunx wrangler deploy`(前端先 `bun run build`);`PUBLIC_BASE_URL` 即 Email Worker 注入的 CONSOLE_URL 5. `bunx wrangler secret put SESSION_SECRET --config console/wrangler.jsonc`(≥32 位随机串) -6. Cloudflare Dashboard 创建 OAuth App(client id/secret),配置 `CF_OAUTH_CLIENT_ID/SECRET` vars 与回调 `/api/oauth/cloudflare/callback`;未配置时自动进入 sim 模式(仅供本地) +6. Cloudflare Dashboard 创建 OAuth App(client id/secret),配置 `CF_OAUTH_CLIENT_ID/SECRET` vars 与回调 `https://wmailhub.adx9.com/api/oauth/cloudflare/callback`;未配置时自动进入 sim 模式(仅供本地) + +> 提示:`wrangler.jsonc` 里的 `database_id` 必须先填真实值,否则 `d1 execute` / `deploy` 都会报 `Invalid uuid`。 +> 部署后自检:`curl https://wmailhub.adx9.com/api/health` → `{"ok":true,"name":"WmailHub","version":""}`。 Cron(`*/1 * * * *`)驱动 TTL 清理与 Webhook 重试;Email Worker 由 Console provisioning 自动上传(无需手工部署),catch-all 规则在「域名 → 设置 Email Workers」时自动配置。 diff --git a/console/wrangler.jsonc b/console/wrangler.jsonc index fa1e5de..95ce80c 100644 --- a/console/wrangler.jsonc +++ b/console/wrangler.jsonc @@ -1,12 +1,12 @@ // WmailHub Console —— Cloudflare Workers 部署配置(生产) // 本地开发不需要 wrangler:直接 `bun run dev`。首次部署前: -// 1. `bunx wrangler d1 create wmailhub` -> 填 database_id -// 2. `bunx wrangler r2 bucket create wmailhub` -// 3. `bunx wrangler d1 execute wmailhub --remote --file=./migrations/0001_init.sql` +// 1. `bunx wrangler d1 create wmailhub` -> 填 database_id(已完成) +// 2. `bunx wrangler r2 bucket create wmailhub` (已完成) +// 3. `bunx wrangler d1 execute wmailhub --remote --file=./migrations/0001_init.sql` 起逐个执行 0001~0004 // 4. `bunx wrangler secret put SESSION_SECRET` (>=32 位随机串) // 5. 配置 CF_OAUTH_CLIENT_ID/SECRET/REDIRECT_URI vars(真实 OAuth;缺省走 sim) { - "$schema": "node_modules/wrangler/config-schema.json", + "$schema": "../node_modules/wrangler/config-schema.json", "name": "wmailhub-console", "main": "src/worker.ts", "compatibility_date": "2026-09-01", @@ -15,11 +15,18 @@ "binding": "ASSETS", "not_found_handling": "single-page-application" }, + "routes": [ + // 自定义域名:wmailhub.adx9.com(CF 自动创建 DNS 记录并签发证书) + { + "pattern": "wmailhub.adx9.com", + "custom_domain": true + } + ], "d1_databases": [ { "binding": "DB", "database_name": "wmailhub", - "database_id": "REPLACE_AFTER_D1_CREATE" + "database_id": "cfc47e65-c71e-470f-96db-5bc23e3e31a4" } ], "r2_buckets": [ @@ -33,7 +40,7 @@ "crons": ["*/1 * * * *"] }, "vars": { - // PUBLIC_BASE_URL 改为你的 Console 域名;OAuth redirect 需要在 Cloudflare Dashboard 登记 - "PUBLIC_BASE_URL": "https://wmailhub-console..workers.dev" + // Console 对外地址;OAuth redirect 需在 Cloudflare Dashboard 登记同一域名 + "PUBLIC_BASE_URL": "https://wmailhub.adx9.com" } } diff --git a/package.json b/package.json index bd151bf..3cdb7f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wmailhub", - "version": "2.1.1", + "version": "2.1.2", "description": "WmailHub - 基于 Cloudflare Email Workers 的轻量邮件接收与转发平台(Console 直连 Email Worker)", "private": true, "type": "module",