td-ai-tools 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/cloudflare/SKILL.md +4 -2
- package/skills/cloudflare/assets/wrangler.jsonc +6 -1
- package/skills/cloudflare/references/auth-and-accounts.md +4 -2
- package/skills/cloudflare/references/config-secrets-envs.md +2 -2
- package/skills/cloudflare/references/data-d1-kv-r2.md +1 -1
- package/skills/cloudflare/references/deploy-and-release.md +1 -1
- package/skills/cloudflare/references/domains-and-dns.md +1 -1
- package/skills/cloudflare/references/forms-email-turnstile.md +65 -9
- package/skills/cloudflare/references/launch-new-site.md +6 -4
- package/skills/cloudflare/references/site-lifecycle.md +1 -0
- package/skills/cloudflare/references/troubleshooting.md +2 -1
package/package.json
CHANGED
|
@@ -8,6 +8,8 @@ description: Operate Theory Digital's Cloudflare-hosted sites (Leyline / Astro o
|
|
|
8
8
|
|
|
9
9
|
Theory Digital sites are Astro apps using the Leyline integration, built with `@astrojs/cloudflare` and deployed as **Workers with static assets** (not Pages). Some sites live in the Theory Digital account, some in the client's own account. This skill is the operating manual: SKILL.md gives the ground rules and routes you to one focused reference file per task.
|
|
10
10
|
|
|
11
|
+
**Default account: `Kyle@theorydigital.ca`.** Unless the user names another account or client, or the site's `account_id` pins a different one, assume work happens as the Cloudflare login `Kyle@theorydigital.ca` and in the Theory Digital account it owns. When creating something new (a Worker, zone, D1 database, Turnstile widget), create it there.
|
|
12
|
+
|
|
11
13
|
## 1. Orient before acting (always)
|
|
12
14
|
|
|
13
15
|
Run the read-only preflight from the site's root. It reports wrangler version, who is logged in, the active auth profile, the Worker name, `account_id`, routes/domains, bindings, and git state:
|
|
@@ -18,7 +20,7 @@ bash <skill-dir>/scripts/preflight.sh [site-dir]
|
|
|
18
20
|
|
|
19
21
|
From that output, answer three questions before any remote write:
|
|
20
22
|
|
|
21
|
-
1. **Which account?** The config's `account_id` (or the profile bound to this directory) must match the client this site belongs to. A mismatch is the most damaging mistake available here: it can create a duplicate Worker, or attach a domain, in the wrong client's account. If `account_id` is missing and the login can see more than one account, stop and set it. See `references/auth-and-accounts.md`.
|
|
23
|
+
1. **Which account?** Check that `whoami` shows `Kyle@theorydigital.ca` (the default) or whichever account the user named; if it shows another login, say so before any remote write. The config's `account_id` (or the profile bound to this directory) must match the client this site belongs to. A mismatch is the most damaging mistake available here: it can create a duplicate Worker, or attach a domain, in the wrong client's account. If `account_id` is missing and the login can see more than one account, stop and set it. See `references/auth-and-accounts.md`.
|
|
22
24
|
2. **Which Worker / environment?** Read `name` and any `env.*` blocks. `--env staging` deploys a *different* Worker (`<name>-staging`).
|
|
23
25
|
3. **Is the tree clean and built from the right commit?** Deploying uncommitted work makes the deploy hard to reproduce or roll back to.
|
|
24
26
|
|
|
@@ -51,7 +53,7 @@ Read only the file for the task at hand. Each one is self-contained.
|
|
|
51
53
|
| Zone settings: AI crawlers / bot blocking, redirects, cache rules, SSL/TLS, HSTS, security | `references/zone-settings.md` |
|
|
52
54
|
| Secrets, vars, `.dev.vars`, environments (staging/prod), `wrangler.jsonc` structure | `references/config-secrets-envs.md` |
|
|
53
55
|
| D1 (create, migrate, query, back up, restore), KV, R2 media buckets | `references/data-d1-kv-r2.md` |
|
|
54
|
-
| Forms stack: Postmark, Turnstile widgets, Email Routing, SPF/DKIM/DMARC | `references/forms-email-turnstile.md` |
|
|
56
|
+
| Forms stack: Postmark or Cloudflare Email Sending, Turnstile widgets, Email Routing, SPF/DKIM/DMARC | `references/forms-email-turnstile.md` |
|
|
55
57
|
| Logs, tailing, observability, analytics, "the site is down" triage | `references/observability-and-incidents.md` |
|
|
56
58
|
| GitHub Actions / Workers Builds, per-PR previews, CI tokens | `references/ci-cd.md` |
|
|
57
59
|
| Inventory/audit across accounts, hand a site to a client's account, decommission, wrangler/compat-date upgrades | `references/site-lifecycle.md` |
|
|
@@ -26,9 +26,14 @@
|
|
|
26
26
|
// Turnstile sitekey (public). Remove if the site has no Turnstile.
|
|
27
27
|
"PUBLIC_TURNSTILE_SITE_KEY": "<SITEKEY>"
|
|
28
28
|
},
|
|
29
|
-
// Secrets (never in this file): FORM_SIGNING_SECRET,
|
|
29
|
+
// Secrets (never in this file): FORM_SIGNING_SECRET, TURNSTILE_SECRET_KEY,
|
|
30
|
+
// POSTMARK_SERVER_TOKEN (Postmark transport only)
|
|
30
31
|
// local: .dev.vars production: npx wrangler secret put NAME
|
|
31
32
|
|
|
33
|
+
// Forms with `transport: 'cloudflare'`: Email Sending. Onboard the domain first:
|
|
34
|
+
// npx wrangler email sending enable <domain>. Remove for the Postmark transport.
|
|
35
|
+
"send_email": [{ "name": "EMAIL", "allowed_sender_addresses": ["web@<DOMAIN>"] }],
|
|
36
|
+
|
|
32
37
|
// Forms with `persist`: store submissions. `npx wrangler d1 create <client>-site --location enam`
|
|
33
38
|
"d1_databases": [
|
|
34
39
|
{
|
|
@@ -7,6 +7,8 @@ Theory Digital has a mixed setup: most sites run in the Theory Digital account,
|
|
|
7
7
|
| **Wrangler OAuth login** (per profile) | `wrangler …` | Workers, D1, KV, R2, secrets, Turnstile, routes/custom domains |
|
|
8
8
|
| **API token** (`CLOUDFLARE_API_TOKEN`) | `scripts/cf-api.sh`, CI, and wrangler too when set | Anything with matching permissions, including zone settings and DNS, which wrangler can't touch |
|
|
9
9
|
|
|
10
|
+
**Default login: `Kyle@theorydigital.ca`.** Unless the user specifies otherwise (or the site's `account_id` belongs to a different account), assume wrangler and API work run as `Kyle@theorydigital.ca` against the Theory Digital account it owns. `npx wrangler whoami` prints the logged-in email; if it's someone else, tell the user and ask before switching (`npx wrangler logout && npx wrangler login`, or a named profile below). An API token in `CLOUDFLARE_API_TOKEN` should likewise belong to that login or be scoped to that account.
|
|
11
|
+
|
|
10
12
|
When `CLOUDFLARE_API_TOKEN` is set in the environment, **wrangler uses it instead of the OAuth login**. Most "wrong account", "Authentication error [code: 10000]" and "permission denied" confusion comes from a stale token in the shell. Check `env | grep CLOUDFLARE_` first.
|
|
11
13
|
|
|
12
14
|
## Wrangler login and profiles
|
|
@@ -18,7 +20,7 @@ npx wrangler login # default profile, browser OAuth
|
|
|
18
20
|
|
|
19
21
|
Named profiles (experimental in wrangler 4.14x, but they work well for mixed accounts):
|
|
20
22
|
```bash
|
|
21
|
-
npx wrangler auth create td # TD
|
|
23
|
+
npx wrangler auth create td # TD login (Kyle@theorydigital.ca, the default)
|
|
22
24
|
npx wrangler auth create client-acme # a login that can see Acme's account
|
|
23
25
|
npx wrangler auth activate client-acme ~/sites/acme # bind a directory → profile
|
|
24
26
|
npx wrangler auth list
|
|
@@ -28,7 +30,7 @@ Even with a profile bound, still set `account_id` in `wrangler.jsonc`. A login t
|
|
|
28
30
|
|
|
29
31
|
**WSL / headless login**: the OAuth callback goes to `localhost:8976`. In WSL2 the browser usually opens on Windows and the callback works. If it doesn't, copy the printed URL into a browser manually. If that callback fails too, use an API token instead.
|
|
30
32
|
|
|
31
|
-
**Account selection**: `npx wrangler whoami` lists account names and IDs. When the user names a client, match the name in that list and confirm the ID with them before writing it to the config. Similar names (e.g. "Acme" vs "Acme Holdings") are common.
|
|
33
|
+
**Account selection**: `npx wrangler whoami` lists account names and IDs. With no client named, use the Theory Digital account under `Kyle@theorydigital.ca`. When the user names a client, match the name in that list and confirm the ID with them before writing it to the config. Similar names (e.g. "Acme" vs "Acme Holdings") are common.
|
|
32
34
|
|
|
33
35
|
## API tokens for `cf-api.sh` and CI
|
|
34
36
|
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
| Kind | Example | Where | In git? |
|
|
6
6
|
|---|---|---|---|
|
|
7
|
-
| Bindings | D1, KV, R2, ratelimits | `wrangler.jsonc` | yes |
|
|
7
|
+
| Bindings | D1, KV, R2, ratelimits, `send_email` | `wrangler.jsonc` | yes |
|
|
8
8
|
| Public/plain vars | `PUBLIC_TURNSTILE_SITE_KEY` | `wrangler.jsonc` → `vars` | yes |
|
|
9
|
-
| Secrets | `FORM_SIGNING_SECRET`, `POSTMARK_SERVER_TOKEN
|
|
9
|
+
| Secrets | `FORM_SIGNING_SECRET`, `POSTMARK_SERVER_TOKEN` (Postmark transport), `TURNSTILE_SECRET_KEY` | `wrangler secret put` (prod), `.dev.vars` (local) | **no** |
|
|
10
10
|
| Build-time site config | `site.url`, locales, forms | `astro.config.ts` (`leyline({...})`) | yes |
|
|
11
11
|
|
|
12
12
|
Leyline reads these through `astro:env`. A var or secret missing at runtime shows up as a startup or first-request error naming the key (see `troubleshooting.md`).
|
|
@@ -59,7 +59,7 @@ A restore rewinds every table, including legitimate submissions received since t
|
|
|
59
59
|
```sql
|
|
60
60
|
-- recent
|
|
61
61
|
SELECT form, locale, status, created_at FROM leyline_submissions ORDER BY created_at DESC LIMIT 20;
|
|
62
|
-
-- delivery failures (Postmark errors)
|
|
62
|
+
-- delivery failures (Postmark or Cloudflare E_… errors)
|
|
63
63
|
SELECT id, form, error, created_at FROM leyline_submissions WHERE status = 'failed' ORDER BY created_at DESC;
|
|
64
64
|
-- volume per day
|
|
65
65
|
SELECT substr(created_at,1,10) AS day, count(*) FROM leyline_submissions GROUP BY day ORDER BY day DESC LIMIT 30;
|
|
@@ -63,7 +63,7 @@ Two mechanisms; choose based on what's needed.
|
|
|
63
63
|
```bash
|
|
64
64
|
npx wrangler versions upload --preview-alias "$(git branch --show-current | tr '/_' '--' | cut -c1-40)"
|
|
65
65
|
```
|
|
66
|
-
This gives `https://<alias>-<worker>.<subdomain>.workers.dev`. The preview shares production bindings, so **form submissions hit the real D1 and send real email**. Warn the user
|
|
66
|
+
This gives `https://<alias>-<worker>.<subdomain>.workers.dev`. The preview shares production bindings, so **form submissions hit the real D1 and send real email**. Warn the user. With the Postmark transport you can point it at a test server for previews; with the Cloudflare transport the preview sends through the same `send_email` binding. The alias URL stays stable across uploads on the same branch.
|
|
67
67
|
|
|
68
68
|
2. **`wrangler preview`** (open beta). It creates a named Preview (defaulting to the git branch) with its own deployments and its own secrets (`wrangler preview secret put`). It uses the Preview base config from the dashboard unless you pass `--ignore-base-config`. It isolates secrets better, but it's beta: check `npx wrangler preview --help`, and expect behaviour to change.
|
|
69
69
|
|
|
@@ -47,7 +47,7 @@ The response contains `name_servers`, the two to give to the registrar.
|
|
|
47
47
|
```bash
|
|
48
48
|
bash scripts/cf-api.sh GET '/zones/{zone:acme.com}/dns_records?per_page=500' | jq -r '.result[] | [.type,.name,.content,.proxied] | @tsv'
|
|
49
49
|
```
|
|
50
|
-
Add anything missing. MX, SPF, DKIM, DMARC and verification TXT records must be **DNS-only** (`"proxied": false`); MX and TXT can't be proxied anyway. Records for other web hosts (subdomains not served by this Worker) can be proxied if their origin supports HTTPS; if unsure, keep them DNS-only to start.
|
|
50
|
+
Add anything missing. MX, SPF, DKIM, DMARC and verification TXT records must be **DNS-only** (`"proxied": false`); MX and TXT can't be proxied anyway, but the **A/AAAA record of each MX target** (e.g. `mail.acme.com`) can be, and the import often proxies it. A proxied mail host resolves to Cloudflare IPs and all inbound mail bounces, so set those records DNS-only. Records for other web hosts (subdomains not served by this Worker) can be proxied if their origin supports HTTPS; if unsure, keep them DNS-only to start.
|
|
51
51
|
|
|
52
52
|
Bulk alternative: build a BIND zone file and `POST /zones/{id}/dns_records/import` (multipart form, `file=@zone.txt`). That endpoint needs `curl -F` directly; `cf-api.sh` sends JSON only.
|
|
53
53
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# Forms, email and Turnstile
|
|
2
2
|
|
|
3
|
-
Leyline forms post to the site's own Worker (`/_leyline/forms/<id
|
|
3
|
+
Leyline forms post to the site's own Worker (`/_leyline/forms/<id>`, and fetch a token from `/_leyline/token/<id>`; both take a trailing slash when `site.trailingSlash: 'always'`). It validates the submission, optionally stores it in D1, and sends the notification (plus the optional visitor confirmation) through the form's **transport**: Postmark or Cloudflare Email Sending. Cloudflare's part is Turnstile, rate limiting, D1, the DNS that makes email work, and, with the Cloudflare transport, the sending itself.
|
|
4
4
|
|
|
5
5
|
## Contents
|
|
6
|
+
- Choosing a transport
|
|
6
7
|
- Turnstile widgets
|
|
8
|
+
- Cloudflare Email Sending setup
|
|
7
9
|
- Postmark DNS (DKIM / Return-Path)
|
|
8
10
|
- Email Routing (receive mail at the domain)
|
|
9
11
|
- SPF / DMARC hygiene
|
|
@@ -11,6 +13,32 @@ Leyline forms post to the site's own Worker (`/_leyline/forms/<id>`). It validat
|
|
|
11
13
|
|
|
12
14
|
---
|
|
13
15
|
|
|
16
|
+
## Choosing a transport
|
|
17
|
+
|
|
18
|
+
Set per form in `astro.config.ts` (Leyline ≥ 0.6.0). Sites usually share one `mail` object across forms:
|
|
19
|
+
```ts
|
|
20
|
+
const mail = { to: 'info@acme.com', from: 'Acme <web@acme.com>', transport: 'cloudflare' } as const;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| | `transport: 'postmark'` (default) | `transport: 'cloudflare'` |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| Needs | Postmark server + `POSTMARK_SERVER_TOKEN` secret, verified sender signature/domain | Account on **Workers Paid**, domain onboarded to Email Sending, `send_email` binding |
|
|
26
|
+
| Cost | Postmark plan | 3,000 emails/mo per account included, then $0.35 / 1,000 |
|
|
27
|
+
| Maturity | Proven deliverability, detailed activity UI | **Open beta**; new accounts start on a conservative (unpublished) daily quota; ~7 days of message preview |
|
|
28
|
+
|
|
29
|
+
Default for new sites: `cloudflare` when the zone is on Cloudflare DNS and the account is on Workers Paid; otherwise Postmark. Keep Postmark for clients where a missed lead is costly until Email Sending is GA. The free 3,000 quota is per **account**: a site handed off to a client's own account needs that account on Workers Paid (see `site-lifecycle.md`).
|
|
30
|
+
|
|
31
|
+
### Visitor confirmation
|
|
32
|
+
|
|
33
|
+
Add `confirmation` to the form (or the shared `mail` object) to also email the visitor, at the form's `replyTo` email field. It goes through the same transport, from `confirmation.from` (default: the form's `from`), with Reply-To set to the form's `to`, so a visitor's reply reaches the business inbox:
|
|
34
|
+
```ts
|
|
35
|
+
confirmation: {
|
|
36
|
+
subject: 'We got your message — Acme',
|
|
37
|
+
body: 'Thanks for getting in touch. We will get back to you as soon as we can.\n\nIf it is urgent, call us at 555-0100.',
|
|
38
|
+
},
|
|
39
|
+
```
|
|
40
|
+
`body` is plain text; blank lines separate paragraphs. A copy of the answers is appended unless `includeSubmission: false`. Have the user confirm the copy: don't promise a response time the client hasn't. Submissions flagged `[unverified]` get no confirmation, and a failed confirmation is only logged; it never fails the submission.
|
|
41
|
+
|
|
14
42
|
## Turnstile widgets
|
|
15
43
|
|
|
16
44
|
```bash
|
|
@@ -27,6 +55,28 @@ npx wrangler turnstile widget update <sitekey> --domain acme.com --domain www.ac
|
|
|
27
55
|
- Leyline checks that the Turnstile *action* matches the form ID.
|
|
28
56
|
- Local dev: Cloudflare's test keys (sitekey `1x00000000000000000000AA`, secret `1x0000000000000000000000000000000AA`) always pass. Leyline allows them through the action check.
|
|
29
57
|
|
|
58
|
+
## Cloudflare Email Sending setup
|
|
59
|
+
|
|
60
|
+
The domain must use Cloudflare DNS. Onboarding adds records on a `cf-bounce` subdomain (MX, SPF, DKIM at `cf-bounce._domainkey`) and does **not** touch the apex MX, so it coexists with Google Workspace / Microsoft 365.
|
|
61
|
+
```bash
|
|
62
|
+
npx wrangler email sending list # what's already onboarded in the account
|
|
63
|
+
npx wrangler email sending enable acme.com # (confirm) creates DNS records in the zone
|
|
64
|
+
npx wrangler email sending settings acme.com # status
|
|
65
|
+
npx wrangler email sending dns get acme.com # records it expects; compare with the zone
|
|
66
|
+
```
|
|
67
|
+
(Open beta. Run `--help` if a command or flag is rejected.)
|
|
68
|
+
|
|
69
|
+
- DMARC: onboarding wants a `_dmarc` TXT. If the zone already has one, keep exactly one record; don't let a second be added. Same advice as below: start at `p=none`.
|
|
70
|
+
- Add the binding to the site's `wrangler.jsonc`, locked to the sender:
|
|
71
|
+
```jsonc
|
|
72
|
+
"send_email": [{ "name": "EMAIL", "allowed_sender_addresses": ["web@acme.com"] }]
|
|
73
|
+
```
|
|
74
|
+
Don't use `destination_address` / `allowed_destination_addresses` if the form sends visitor confirmations: those go to arbitrary addresses. A different binding name needs `emailBinding: '<NAME>'` in the form config.
|
|
75
|
+
- No secret is needed. `POSTMARK_SERVER_TOKEN` can be left unset.
|
|
76
|
+
- `wrangler dev` simulates the binding: emails are logged to the console (`send_email binding called with MessageBuilder`) and **not** sent. To send for real from dev, add `"remote": true` to the binding temporarily. It sends real mail.
|
|
77
|
+
- With `persist`, apply local migrations against the config `wrangler dev` runs (`npx wrangler d1 migrations apply DB --local -c dist/server/wrangler.json`). Applying them with the root `wrangler.jsonc` writes a different local state, and submissions fail with `no such table: leyline_submissions` (a 502 in the browser).
|
|
78
|
+
- Test end to end on a preview or production deploy: notification arrives, Reply-To is the visitor, headers show SPF/DKIM/DMARC pass.
|
|
79
|
+
|
|
30
80
|
## Postmark DNS
|
|
31
81
|
|
|
32
82
|
Postmark (Sender Signatures / Domains) gives a **DKIM TXT** record (`<selector>._domainkey`) and a **Return-Path CNAME** (`pm-bounces` → `pm.mtasv.net`). Add both in the zone, **DNS-only** (confirm):
|
|
@@ -45,9 +95,7 @@ npx wrangler email routing enable acme.com # (confirm) a
|
|
|
45
95
|
npx wrangler email routing addresses --help # destination addresses must be verified by the recipient clicking an email
|
|
46
96
|
npx wrangler email routing rules --help # map hello@ → destination
|
|
47
97
|
```
|
|
48
|
-
Leyline forms can `to:` a routed address. Delivery then goes Postmark → Cloudflare Email Routing → the client's inbox.
|
|
49
|
-
|
|
50
|
-
Cloudflare **Email Sending** (`wrangler email sending`) is a newer alternative to Postmark for outbound mail. Leyline doesn't support it as a transport yet, so don't switch a site to it without a code change in Leyline.
|
|
98
|
+
Leyline forms can `to:` a routed address. Delivery then goes Postmark or Email Sending → Cloudflare Email Routing → the client's inbox. Email Routing (receiving) and Email Sending are separate; you don't need Routing to send.
|
|
51
99
|
|
|
52
100
|
## SPF / DMARC hygiene
|
|
53
101
|
|
|
@@ -59,8 +107,16 @@ Cloudflare **Email Sending** (`wrangler email sending`) is a newer alternative t
|
|
|
59
107
|
Work through these in order and stop at the first failure:
|
|
60
108
|
1. **Did the Worker get the submission?** `npx wrangler tail --format pretty --search "[leyline]"`, then submit, or check D1: `SELECT status, error FROM leyline_submissions ORDER BY created_at DESC LIMIT 5`.
|
|
61
109
|
- No row/log → the request isn't reaching the Worker. Check the browser network tab for 403 (origin check), 429 (rate limit) or a Turnstile failure.
|
|
62
|
-
- `status = 'failed'` with
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
110
|
+
- `status = 'failed'` with `Postmark …` → Postmark rejected it. The error text says why: an unverified sender, a wrong stream, or an inactive recipient.
|
|
111
|
+
- `status = 'failed'` with `Cloudflare E_…` → Email Sending rejected it:
|
|
112
|
+
- `E_SENDER_DOMAIN_NOT_AVAILABLE` / `E_SENDER_NOT_VERIFIED`: the `from` domain isn't onboarded or its DNS isn't verified (`email sending settings <domain>`).
|
|
113
|
+
- `E_RECIPIENT_NOT_ALLOWED`: the binding has a destination allowlist that excludes the recipient.
|
|
114
|
+
- `E_RECIPIENT_SUPPRESSED`: the recipient bounced or complained before; check the suppression list in the dashboard (Email Service → Email Sending).
|
|
115
|
+
- `E_RATE_LIMIT_EXCEEDED` / `E_DAILY_LIMIT_EXCEEDED`: quota. New accounts start low; request an increase in the dashboard.
|
|
116
|
+
- `E_ACCOUNT_SUSPENDED`: sending paused for reputation. Escalate to the user.
|
|
117
|
+
- `[leyline] Form "x" misconfigured: send_email binding "EMAIL" is not configured` → the binding is missing from `wrangler.jsonc` (or `emailBinding` doesn't match it).
|
|
118
|
+
2. **Secrets**: `npx wrangler secret list` shows `FORM_SIGNING_SECRET`, plus `POSTMARK_SERVER_TOKEN` for the Postmark transport.
|
|
119
|
+
3. **Provider activity**: in the Postmark UI (delivered, bounced, spam-complained; a hard-bounced recipient stays suppressed until reactivated), or the dashboard's Email Service → Email Sending activity log and metrics (about 7 days of message preview).
|
|
120
|
+
4. **The `to:` mailbox can't receive.** After a zone import, the MX target host (often `mail.<domain>` on cPanel or GoDaddy) can end up **proxied**. It then resolves to Cloudflare IPs, which don't accept SMTP, so every inbound message to the domain bounces, not just form mail. List the zone's MX records, then confirm each target's A/AAAA record is DNS-only (`"proxied": false`). See `domains-and-dns.md`.
|
|
121
|
+
5. **Recipient side**: spam folder, or a Microsoft 365 quarantine. Unverified DKIM / Return-Path (Postmark) or `cf-bounce` records (Email Sending) make this much worse.
|
|
122
|
+
6. **Submission marked `[unverified]` or flagged**: Leyline's spam heuristics. See `flags` in D1. That's working as designed unless legitimate messages are being rejected.
|
|
@@ -99,7 +99,7 @@ See `config-secrets-envs.md` and `forms-email-turnstile.md` for detail.
|
|
|
99
99
|
Local first. Create `.dev.vars` (gitignored):
|
|
100
100
|
```
|
|
101
101
|
FORM_SIGNING_SECRET=<openssl rand -base64 48>
|
|
102
|
-
POSTMARK_SERVER_TOKEN=<from Postmark → server → API tokens>
|
|
102
|
+
POSTMARK_SERVER_TOKEN=<from Postmark → server → API tokens> # Postmark transport only
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
Turnstile, if enabled. The widget needs the production hostname, plus `localhost` if you want it to work in dev:
|
|
@@ -108,7 +108,9 @@ npx wrangler turnstile widget create "acme site" --domain acme.com --domain www.
|
|
|
108
108
|
```
|
|
109
109
|
Put the returned `sitekey` in `vars.PUBLIC_TURNSTILE_SITE_KEY` in `wrangler.jsonc`, and the `secret` in `.dev.vars` as `TURNSTILE_SECRET_KEY`. Treat the secret like a password. Don't repeat it back in chat beyond writing it to the file. For local development, Cloudflare's always-pass test keys work. The Leyline action check lets them through.
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
Email transport (see `forms-email-turnstile.md` → "Choosing a transport"):
|
|
112
|
+
- **Cloudflare** (`transport: 'cloudflare'`): add the `send_email` binding to `wrangler.jsonc`. Onboarding the domain (`wrangler email sending enable`) needs the zone on Cloudflare DNS, so it waits for phase 8 if the zone is moving; until then the form only works in `wrangler dev` (logged, not sent).
|
|
113
|
+
- **Postmark** (default): the `from` address's domain or sender signature must be verified in Postmark *before* launch. If the client's DNS is moving to Cloudflare in phase 8, add the Postmark DKIM and Return-Path records there.
|
|
112
114
|
|
|
113
115
|
## 6. Build and preview locally
|
|
114
116
|
|
|
@@ -116,7 +118,7 @@ Postmark: the `from` address's domain or sender signature must be verified in Po
|
|
|
116
118
|
npx astro build
|
|
117
119
|
npx wrangler dev -c dist/server/wrangler.json --port 4321
|
|
118
120
|
```
|
|
119
|
-
Use this, not `astro preview`. In Astro 7.3 it returns 500s for prerendered pages with `build.format: 'file'`. Click through the main pages and submit a test form (
|
|
121
|
+
Use this, not `astro preview`. In Astro 7.3 it returns 500s for prerendered pages with `build.format: 'file'`. Click through the main pages and submit a test form (Cloudflare transport: the email is logged in the terminal; Postmark: the mock or a real token).
|
|
120
122
|
|
|
121
123
|
✅ Pages render, and the form's token endpoint `/_leyline/token/contact` returns 200.
|
|
122
124
|
|
|
@@ -129,7 +131,7 @@ npx wrangler d1 migrations apply DB --remote # (confirm
|
|
|
129
131
|
npx astro build
|
|
130
132
|
npx wrangler deploy --tag "$(git rev-parse --short HEAD)" --message "Initial deploy" # (confirm)
|
|
131
133
|
printf %s "$(grep ^FORM_SIGNING_SECRET= .dev.vars | cut -d= -f2-)" | npx wrangler secret put FORM_SIGNING_SECRET # (confirm)
|
|
132
|
-
printf %s "$(grep ^POSTMARK_SERVER_TOKEN= .dev.vars | cut -d= -f2-)" | npx wrangler secret put POSTMARK_SERVER_TOKEN
|
|
134
|
+
printf %s "$(grep ^POSTMARK_SERVER_TOKEN= .dev.vars | cut -d= -f2-)" | npx wrangler secret put POSTMARK_SERVER_TOKEN # Postmark transport only
|
|
133
135
|
# + TURNSTILE_SECRET_KEY if used
|
|
134
136
|
```
|
|
135
137
|
Use a *different* `FORM_SIGNING_SECRET` in production than in dev if you like. It only has to be random, 32+ characters, and stable. Rotating it invalidates tokens that are already open in visitors' browsers.
|
|
@@ -46,6 +46,7 @@ Resources can't be "moved" between accounts. You recreate them in the new accoun
|
|
|
46
46
|
- D1: `d1 export --remote` from the old account → `d1 create` in the new → `d1 execute --file` the export. Update `database_id`.
|
|
47
47
|
- Secrets: `secret put` each in the new account (values come from the password manager, `.dev.vars`, or new ones generated; Postmark tokens can stay the same).
|
|
48
48
|
- Turnstile: create a new widget in the new account → new sitekey/secret.
|
|
49
|
+
- Email Sending (Cloudflare transport): the new account needs Workers Paid, and the domain must be onboarded there (`wrangler email sending enable`) once the zone has moved. Until then, form email fails with `E_SENDER_DOMAIN_NOT_AVAILABLE`; switch the site to Postmark temporarily if the gap matters.
|
|
49
50
|
- R2 / KV: copy the objects; `rclone` with the S3 API works for R2.
|
|
50
51
|
4. Update `account_id` in `wrangler.jsonc`. Deploy to the new account's workers.dev and verify there.
|
|
51
52
|
5. **Cut over**: zone nameservers move to the new account's pair (if the zone moved), then attach custom domains in the new account. If both accounts claim the hostname, remove it from the old Worker first, accepting a brief gap, or schedule the change for a quiet time.
|
|
@@ -46,7 +46,8 @@ Look up the error text. Each entry gives the cause and the fix. For "site is dow
|
|
|
46
46
|
| Form shows "please try again" for everyone | Token invalid: the secret was rotated recently (transient), or clock or timing problems. Tail and look for `rejected:` reasons |
|
|
47
47
|
| Form 403 | Origin check: the form was posted from a different host than the Worker sees (preview vs prod mix-up, or a proxy rewriting Host). Astro's `checkOrigin` also blocks cross-site posts |
|
|
48
48
|
| Form 429 | `FORM_RATE_LIMITER` triggered. Expected under spam; if real users hit it, raise `simple.limit` |
|
|
49
|
-
| `Form "x" delivery failed: …` | Postmark rejected it. See `forms-email-turnstile.md` → "Form emails aren't arriving" |
|
|
49
|
+
| `Form "x" delivery failed: …` | Postmark (`Postmark …`) or Email Sending (`Cloudflare E_…`) rejected it. See `forms-email-turnstile.md` → "Form emails aren't arriving" |
|
|
50
|
+
| `Form "x" misconfigured: send_email binding "EMAIL" is not configured` | Cloudflare transport without the binding. Add `send_email` to `wrangler.jsonc` and redeploy |
|
|
50
51
|
| Turnstile error 110200 in the browser console | The page's hostname isn't in the widget's domain list. `turnstile widget update` |
|
|
51
52
|
| robots.txt is missing the "AI crawlers are explicitly welcome" group in production | Cloudflare managed robots.txt is on. See `zone-settings.md` |
|
|
52
53
|
| AI crawlers get 403 | "Block AI bots" or an AI Crawl Control block. See `zone-settings.md` |
|