diff --git a/CHANGELOG.md b/CHANGELOG.md index 112dcbff..4257e3c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - feat: |Skill| 新增仓库内置只读 skill `cf-temp-mail-agent-mail`(`skills/cf-temp-mail-agent-mail/`),让 OpenClaw / Codex / Cursor 等 AI agent 凭用户提供的 Address JWT + API 地址读取邮箱、轮询验证码,绕开创建邮箱时的 Turnstile 人机验证;可通过 `npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail` 安装 - docs: |文档| 新增"AI Agent 使用邮箱"文档(`guide/feature/agent-email`),说明 `parsed_mail` API 用法,并在 parsed API 不可用时给出对齐前端的 `mail-parser-wasm` + `postal-mime` 本地解析回退方案 - docs: |文档| 在 `quick-start` / `worker-vars` / `email-routing` 三个入口文档(中英文)显式补充"域名是部署前提条件"提示,强调需先在 Cloudflare 启用 Email Routing 并下发邮件 DNS 记录、Worker 部署后再绑定 Catch-all,子域名需单独启用,避免用户在没有可用域名时直接开始部署却收不到邮件(issue #1004) +- docs: |部署排障| 优化近期 issue 暴露的 UI 部署与升级排障文档:补充 `nodejs_compat`、D1 绑定名必须为 `DB`、`/open_api/settings` 校验、后端 API 地址填写、Cloudflare 安全挑战导致 `Network Error`、D1 容量上限与 Cron Trigger 自动清理、GitHub OAuth 公开邮箱、admin 管理口令与用户账号区别、随机二级域名 API 需传 `enableRandomSubdomain` 等说明;同时将帮助/FAQ 菜单移动到核心配置之后,提升可见性 ### Bug Fixes diff --git a/CHANGELOG_EN.md b/CHANGELOG_EN.md index 8c6d4abd..dde8f255 100644 --- a/CHANGELOG_EN.md +++ b/CHANGELOG_EN.md @@ -15,6 +15,7 @@ - feat: |Skill| Bundle a read-only skill `cf-temp-mail-agent-mail` (`skills/cf-temp-mail-agent-mail/`) so AI agents like OpenClaw / Codex / Cursor can consume a mailbox with a user-supplied Address JWT + API base URL — list mails, poll verification codes, etc. — sidestepping the Turnstile challenge required to create a mailbox. Install via `npx degit dreamhunter2333/cloudflare_temp_email/skills/cf-temp-mail-agent-mail` - docs: |Docs| Add "AI Agent Mailbox Usage" doc (`guide/feature/agent-email`) covering the `parsed_mail` API and a local-parse fallback using `mail-parser-wasm` + `postal-mime` (mirrors the frontend) when parsed endpoints are unavailable - docs: |Docs| Make "a domain is a hard prerequisite" explicit at the top of `quick-start`, `worker-vars`, and `email-routing` (zh + en), spelling out that Cloudflare Email Routing must be enabled with email DNS records provisioned before deployment, the Catch-all rule must be bound after the Worker is deployed, and subdomains do not inherit the parent domain's Email Routing — so users no longer start deploying without a usable domain and end up unable to receive mail (issue #1004) +- docs: |Deployment troubleshooting| Improve docs for recent UI-deployment and upgrade issues: document `nodejs_compat`, the required uppercase `DB` D1 binding, `/open_api/settings` verification, backend API URL entry, Cloudflare security challenges causing `Network Error`, D1 size limits and Cron Trigger cleanup, GitHub OAuth public email requirements, the difference between admin passwords and user accounts, and the `enableRandomSubdomain` API flag; move the Help/FAQ menu directly after Core Configuration so it is easier to find ### Bug Fixes diff --git a/vitepress-docs/docs/.vitepress/en.ts b/vitepress-docs/docs/.vitepress/en.ts index cd2e25b8..b08f0159 100644 --- a/vitepress-docs/docs/.vitepress/en.ts +++ b/vitepress-docs/docs/.vitepress/en.ts @@ -143,6 +143,13 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] { { text: 'Configure Email Sending', link: 'config-send-mail' }, ] }, + { + text: 'Help', + collapsed: false, + items: [ + { text: 'FAQ', link: 'common-issues' }, + ] + }, { text: 'Notifications & Integrations', collapsed: false, @@ -184,13 +191,6 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] { { text: 'Admin User Management', link: 'feature/admin-user-management' }, ] }, - { - text: 'Help', - collapsed: false, - items: [ - { text: 'FAQ', link: 'common-issues' }, - ] - }, { text: 'Reference', base: "/en/", link: 'reference' } ] } diff --git a/vitepress-docs/docs/.vitepress/zh.ts b/vitepress-docs/docs/.vitepress/zh.ts index 12998db7..9ff23e79 100644 --- a/vitepress-docs/docs/.vitepress/zh.ts +++ b/vitepress-docs/docs/.vitepress/zh.ts @@ -143,6 +143,13 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] { { text: '配置发送邮件', link: 'config-send-mail' }, ] }, + { + text: '帮助', + collapsed: false, + items: [ + { text: '常见问题 (FAQ)', link: 'common-issues' }, + ] + }, { text: '通知与集成', collapsed: false, @@ -184,13 +191,6 @@ function sidebarGuide(): DefaultTheme.SidebarItem[] { { text: 'Admin 用户管理', link: 'feature/admin-user-management' }, ] }, - { - text: '帮助', - collapsed: false, - items: [ - { text: '常见问题 (FAQ)', link: 'common-issues' }, - ] - }, { text: '参考', base: "/zh/", link: 'reference' } ] } diff --git a/vitepress-docs/docs/en/guide/common-issues.md b/vitepress-docs/docs/en/guide/common-issues.md index 32ed491a..b34c2310 100644 --- a/vitepress-docs/docs/en/guide/common-issues.md +++ b/vitepress-docs/docs/en/guide/common-issues.md @@ -19,16 +19,19 @@ | `No such module "node:stream". imported from "worker.js"` | [Reference](/en/guide/ui/worker) | | `Subdomain cannot send emails` | [Reference](https://github.com/dreamhunter2333/cloudflare_temp_email/issues/515) | | `Failed to send verify code: No balance` | Set unlimited emails in admin console or increase quota on the sending permission page | -| `Github OAuth unable to get email 400 Failed to get user email` | GitHub user needs to set email to public | +| `GitHub OAuth unable to get email` / `[400]: Failed to get user email from OAuth2 provider` | The GitHub template reads the `email` field from `https://api.github.com/user`. If the GitHub account hides its public email, this field is `null`. Make the email public in the GitHub profile, or use an OAuth2 provider/API that returns an email field | | `Cannot read properties of undefined (reading 'map')` during page initialization | First check whether `/open_api/settings` is returning valid data. In a direct Worker deployment, this usually means Worker variables were not configured correctly, so verify JSON-format variables such as `DOMAINS` and `ADMIN_PASSWORDS`. If this happens in a Pages deployment because requests are going to the wrong backend address, continue with the Pages troubleshooting section below | +| Worker backend opens as `OK`, but every frontend request shows `Network Error` | First open the frontend in an incognito window to rule out a cached old frontend bundle. Then make sure Cloudflare security modes such as Under Attack, Bot Fight, or Managed Challenge are not applied to the API domain; those browser challenges block XHR/API requests and surface as `Network Error` | +| Mail suddenly stops arriving, deleting a few mails makes it work again, and Worker logs show `D1_ERROR: Exceeded maximum DB size` | The D1 database has reached its per-database size limit and can no longer write `raw_mails`. Delete old mails, enable auto cleanup in the admin console, and make sure the Worker has a `Settings -> Trigger Events -> Cron Triggers` schedule; otherwise admin cleanup settings will not run automatically | ## Pages Related | Issue | Solution | | --------------- | --------------------------------------------------------- | -| `network error` | Use incognito mode or clear browser cache and DNS cache | +| `Network Error` | First use incognito mode or clear browser cache and DNS cache; then inspect the failed request URL, status code, and response body in the browser DevTools Network panel | | Pages deployment shows the `map` error, or API requests such as `/admin/users` / `/admin/new_address` return `405 Method Not Allowed` | This is usually caused by an incorrect frontend backend address. Check `VITE_API_BASE`, the URL entered when generating the zip in the UI guide, or `FRONTEND_ENV`: for separate frontend/backend deployment talking directly to Worker, it should be the backend Worker API root URL, start with `https://`, and have no trailing `/`; if you use `PAGE_TOML` to proxy backend requests through Page Functions, `VITE_API_BASE` can be left empty to use same-origin requests. See [Pages Frontend Deployment](/en/guide/ui/pages) | | Refreshing page or directly visiting `/admin`, `/user` returns 404 | This project is a Single-Page Application (SPA). When deploying Pages via UI, set "Not Found handling" to `Single-page application (SPA)` in the advanced options. See [Pages Frontend Deployment](/en/guide/ui/pages) | +| Admin login shows `Network Error` and the request is `/open_api/admin_login` | Check that the backend API root URL used when generating the frontend zip is the Worker domain, not the Pages domain; it must not include `/admin`, `/api`, or a trailing `/`. Also confirm the response is not a Cloudflare security challenge page | ## Email Sending Related diff --git a/vitepress-docs/docs/en/guide/feature/admin.md b/vitepress-docs/docs/en/guide/feature/admin.md index f6678050..c0a82c28 100644 --- a/vitepress-docs/docs/en/guide/feature/admin.md +++ b/vitepress-docs/docs/en/guide/feature/admin.md @@ -8,6 +8,19 @@ After deploying the frontend application, click the upper-left logo 5 times or v You need to configure `ADMIN_PASSWORDS` in the backend or ensure the current user role is `ADMIN_USER_ROLE`, otherwise access to the console will be denied. +## Admin Passwords vs User Accounts + +`ADMIN_PASSWORDS` is the management password for the Admin console. It is not a site user account +and does not correspond to any mailbox address. Logging in with an admin password grants access to +the console, but that login itself cannot receive mail. + +Site user accounts are stored in the `users` table and use the user login flow. Whether a user can +receive mail depends on whether they created or bound a mailbox address. Creating a normal user +whose email looks like `admin@example.com` does not automatically grant admin permissions. + +If you want a user account to access the Admin console, configure `ADMIN_USER_ROLE` and assign the +same role to that user in user management. +  ## Account List Sorting diff --git a/vitepress-docs/docs/en/guide/feature/subdomain.md b/vitepress-docs/docs/en/guide/feature/subdomain.md index 0056fa51..a15b6e90 100644 --- a/vitepress-docs/docs/en/guide/feature/subdomain.md +++ b/vitepress-docs/docs/en/guide/feature/subdomain.md @@ -30,9 +30,29 @@ RANDOM_SUBDOMAIN_LENGTH = 8 - `RANDOM_SUBDOMAIN_DOMAINS`: base domains that allow optional random second-level subdomains - `RANDOM_SUBDOMAIN_LENGTH`: random string length, range `1-63`, default `8` +The create-address APIs only generate a random subdomain when the request explicitly passes +`enableRandomSubdomain: true`. The frontend sends this field when the "enable random subdomain" +option is checked. If you call `/api/new_address` or `/admin/new_address` yourself, include it in +the request body: + +```json +{ + "name": "test", + "domain": "abc.com", + "enableRandomSubdomain": true +} +``` + +`domain` must be the base domain configured in `RANDOM_SUBDOMAIN_DOMAINS`, such as `abc.com`. +If you want to create an address under a specific subdomain such as `team.abc.com`, do not pass +`enableRandomSubdomain: true`; use the direct-subdomain flow below instead. + > [!NOTE] > This feature only appends a random second-level subdomain when the mailbox is created. > +> There is currently no backend switch that globally forces random subdomains; API calls that do +> not pass `enableRandomSubdomain: true` will not randomize automatically. +> > It does not automatically create Cloudflare-side subdomain mail routes or DNS records for you, > so make sure the base-domain/subdomain routing is already available first. diff --git a/vitepress-docs/docs/en/guide/feature/user-oauth2.md b/vitepress-docs/docs/en/guide/feature/user-oauth2.md index 85bd2cc5..c6ad6961 100644 --- a/vitepress-docs/docs/en/guide/feature/user-oauth2.md +++ b/vitepress-docs/docs/en/guide/feature/user-oauth2.md @@ -10,6 +10,12 @@ ### GitHub - Please first create an OAuth App, then obtain the `Client ID` and `Client Secret` +- The default GitHub template uses `https://api.github.com/user` as the user info endpoint and reads + the `email` field from the returned JSON. If the GitHub account hides its public email, this field + is `null`, and login returns `[400]: Failed to get user email from OAuth2 provider`. +- Fix it by making the email public in the GitHub profile, or by using a provider/API that returns + an email field. If the returned value is not a standard email, use the "Email Format + Transformation" section below. Reference: [Creating an OAuth App](https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app) @@ -41,6 +47,17 @@ Reference: [Creating an OAuth App](https://docs.github.com/en/apps/oauth-apps/bu | Redirect URL | OAuth2 callback URL | | Scope | OAuth2 permission scope | +`Redirect URL` must exactly match the callback URL configured in the third-party OAuth App. The +default frontend callback path is: + +```text +https://your-frontend-domain/user/oauth2/callback +``` + +Even if your site uses locale-prefixed routes, it is still recommended to configure the OAuth +provider with the callback URL without a locale prefix to avoid callback mismatches between +languages. + ### Email Format Transformation When OAuth2 returns a non-standard email format (e.g., returns a user ID), you can enable the Email Format feature. diff --git a/vitepress-docs/docs/en/guide/quick-start.md b/vitepress-docs/docs/en/guide/quick-start.md index d8b85db7..956a3cc3 100644 --- a/vitepress-docs/docs/en/guide/quick-start.md +++ b/vitepress-docs/docs/en/guide/quick-start.md @@ -30,6 +30,13 @@ Then review all changes from your current version onwards. Note that `Breaking C Then refer to the documentation below to use `CLI` or `UI` to redeploy the `worker` and `pages` over the previous deployment. +Upgrading does not mean editing the old code already running in the Cloudflare console. It means redeploying the new version artifacts over the existing Worker and Pages deployment: + +- If you use UI deployment, download the latest release `worker.js` and `frontend.zip`, then upload them again using the same deployment method. +- If you use GitHub Actions, sync your fork first and rerun the corresponding workflow. +- If the changelog lists database changes, run the upgrade in `Admin -> Quick Setup -> Database`, or execute the corresponding SQL according to the D1 guide. +- If the frontend still shows an old error after upgrading, test in an incognito window or clear browser cache so it stops loading the old frontend assets. + ### CLI Deployment - [Update D1 via Command Line](/en/guide/cli/d1) diff --git a/vitepress-docs/docs/en/guide/ui/pages.md b/vitepress-docs/docs/en/guide/ui/pages.md index 4779f1a3..83c7856e 100644 --- a/vitepress-docs/docs/en/guide/ui/pages.md +++ b/vitepress-docs/docs/en/guide/ui/pages.md @@ -115,9 +115,12 @@ const generate = async () => { - The worker domain here is the backend API domain. For example, if I deployed at `https://temp-email-api.awsl.uk`, then fill in `https://temp-email-api.awsl.uk` - If your domain is `https://temp-email-api.xxx.workers.dev`, then fill in `https://temp-email-api.xxx.workers.dev` - Do not enter your frontend `Pages` domain, and do not include paths like `/admin` or `/api`. Otherwise frontend requests will hit the wrong address and you may see `Cannot read properties of undefined (reading 'map')` or `405 Method Not Allowed` + - Before filling it in, open `https://your-worker-domain/open_api/settings` in the browser and confirm it returns JSON. If it returns HTML, 404, 405, or a Cloudflare challenge page, fix the Worker binding, variables, or security policy first > [!warning] Note > The `worker.dev` domain is not accessible in China, please use a custom domain. + > + > Do not enable security policies such as Under Attack, Bot Fight, or Managed Challenge on the backend API domain. Frontend XHR requests cannot complete those browser challenges, and the common symptom is `Network Error`.