From dcf820b365d0c628ddfdaa47ebc359a4868cae98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Smoli=C5=84ski?= Date: Tue, 1 Dec 2026 18:01:21 +0100 Subject: [PATCH] F3 docs: HTML pages keep Next's own Vary and their ISR caching (measured on the built reference site, both bundlers); the private, no-store Markdown answer is what closes F3 Co-Authored-By: Claude Opus 5.5 --- docs/CHANGELOG.md | 2 +- docs/agent/AGENT.md | 2 +- docs/agent/skills/iapl-upgrade/SKILL.md | 2 +- docs/content.md | 4 +++- reference/.agents/skills/iapl-upgrade/SKILL.md | 2 +- src/modules/i18n/createProxy.ts | 4 ++-- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index f30ee08..3be3afe 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -120,7 +120,7 @@ This heading and the 1.17.2 section below (never released on its own) become one > panel works as before. Off: `lockedDocuments: false`; your own rule: `lockedDocuments: { access: { read } }`. > 4. **The Markdown negotiated at a page URL is never cached as the page** (F3). `createProxy({ markdown: true })` > marks the rewrite, the Markdown route answers `cache-control: private, no-store` with `Vary: Accept`, and the -> pages under the proxy matcher get `Vary: Accept`. Before, a CDN that caches HTML (Cloudflare "Cache Everything", +> HTML pages keep their caching and Next's own `Vary` (ISR unchanged). Before, a CDN that caches HTML (Cloudflare "Cache Everything", > Varnish) could store the Markdown copy after one anonymous `Accept: text/markdown` request and serve it to every > visitor of that page. `/md/…` keeps its public caching. A proxy of your own that rewrites to `/md/…` copies the > headers (`MARKDOWN_NEGOTIATED_HEADER`, `NEGOTIATED_CACHE_CONTROL`, `appendVary`; content.md). Off: diff --git a/docs/agent/AGENT.md b/docs/agent/AGENT.md index 260d32a..f4be6f2 100644 --- a/docs/agent/AGENT.md +++ b/docs/agent/AGENT.md @@ -1260,7 +1260,7 @@ add missing hosts with flags / `extra`; (3) change `mode` to `'enforce'` in both | Operator names in `sort` refused (1.18.0, audit F5): `?sort=$where`, `-$natural`, `a.$ne` → `400` for everyone (logged as one `info` line, `RefusedSortError`) instead of a database error. **Verify:** `curl -s -o /dev/null -w '%{http_code}' '/api/pages?sort=%24where'` → `400` | `refuseOperatorSort: false` | `loggingLevels: { RefusedSortError: false }`; `isOperatorSort` | | Payload's document locks (`payload-locked-documents`) for staff accounts only, with the second factor (1.18.0); Payload's default was any signed-in account, a customer too. **Verify:** a visitor account gets `403` on `/api/payload-locked-documents`; the panel still shows who edits a document | `lockedDocuments: false` | `lockedDocuments: { access: { read, create, update, delete } }`; `staffOnlyLocks`, `applyLockedDocumentsAccess` | | CSP report log lines normalised (1.18.0, audit F1): origin of the blocked resource, path of the page, no control characters, every value ≤ 128 characters; at most 10 violations per request, 60 requests per client a minute (answer stays `204`) | `rateLimit: false`; your own `onReport` (gets the raw values) | `createCspReportRoute({ maxReports, rateLimit: { max, windowMs }, onReport })`, `cspLogLine` | -| Markdown negotiated at a page URL is `private, no-store` + `Vary: Accept`; pages under the proxy matcher get `Vary: Accept` (1.18.0, audit F3); `/md/…` stays publicly cacheable | `markdown: { negotiate: false }` (Markdown only at `/md/…`) | `markdown: { prefix }`; `MARKDOWN_NEGOTIATED_HEADER`, `appendVary` for your own proxy | +| Markdown negotiated at a page URL is `private, no-store` + `Vary: Accept`; HTML keeps Next's own `Vary` and caching (1.18.0, audit F3); `/md/…` stays publicly cacheable | `markdown: { negotiate: false }` (Markdown only at `/md/…`) | `markdown: { prefix }`; `MARKDOWN_NEGOTIATED_HEADER`, `appendVary` for your own proxy | | 2FA first set-up confirmed by e-mail (1.18.0): the code only starts it; a link to the account's own address, opened in the same browser within 30 min, turns it on and ends the account's sessions; notice mails on every enrolment, change, removal / reset; without working mail the link goes to the server log and an admin confirms on the account page ("Confirm the waiting set-up", `POST /api/iapl/two-factor/confirm-pending`). **Verify:** security.md "Set-up confirmed by e-mail" → Verify; doctor `2fa-enrolment-mail` | `twoFactor.confirmByEmail: false` | `confirmByEmail: { linkMinutes, sameBrowser, adminConfirm, logLinkWhenMailFails, notices, maxMailsPerHour }`; `startEnrolment`, `buildEnrolmentEndpoints`, `buildTotpNoticeHooks`, `sendTwoFactorNotice`, `verifyTotpCode`, `readPendingEnrolment`, `pendingEnrolmentInfo`, `countPendingEnrolments`, `mailConfigured` | | 2FA verify and setup attempts only from the site's own origin: a request a browser marks as coming from elsewhere (`Origin`, `Sec-Fetch-Site`) gets `403` and is not counted. The admin's reset `POST /api/ipal/two-factor/reset` follows the same rule (1.17.1). **Verify:** `curl -X POST /api/ipal/two-factor/reset -H 'Origin: https://other.example' -H 'Content-Type: text/plain' -b -d '{"userId":1}'` → `403`; the panel's button still works. **Set `serverURL`**: behind a proxy that rewrites `Host` and sends no `X-Forwarded-Host` the site's own page is refused without it (logged once per origin: `[iapl] 2FA: a code from origin … was refused`) | `twoFactor.sameOrigin: false` | `sameOrigin: { origins: ['https://app.example.com'] }`; `requestFromOwnOrigin`, `reportRefusedOrigin` | | Stored secrets are write-only: `smtpPassword` and `turnstileSecretKey` come back as `'********'` over REST, GraphQL and in the panel; an empty save keeps the value, `'[[clear]]'` removes it; server code reads the real value with the Local API. A query cannot name a secret (1.17.1): `where` / `sort` on it — REST, GraphQL, versions — is refused (`secretReadAccess`, the field's `read` rule; verify: `GET /api/globals/site-integrations/versions?where[version.smtpPassword][exists]=true` as an admin → 400 `QueryError`, no `totalDocs`). **The panel is the source — never add an env variable for them** (`TURNSTILE_SECRET_KEY` is deprecated) | `secrets: { writeOnly: false }` | `writeOnlySecret(field)` / `writeOnlySecrets(fields, names)` for your own secret fields; with versions on the entity add `hooks.afterRead: [maskSecretsOnRestore]` | diff --git a/docs/agent/skills/iapl-upgrade/SKILL.md b/docs/agent/skills/iapl-upgrade/SKILL.md index 7fe2a01..21ecdec 100644 --- a/docs/agent/skills/iapl-upgrade/SKILL.md +++ b/docs/agent/skills/iapl-upgrade/SKILL.md @@ -53,7 +53,7 @@ not staff (REST / GraphQL; the Local API and the panel are not touched): a clien 100 documents anonymously gets `hasNextPage: true` — page through, or `listLimit: { max }` / `{ exclude: ['slug'] }` / `false`; (2) a `?sort=$…` answers `400` (`refuseOperatorSort: false` = Payload's way); (3) Payload's document locks are staff only (`lockedDocuments: false` = Payload's default); (4) the negotiated Markdown at a page URL is -`private, no-store` + `Vary: Accept`, and pages under the proxy matcher get `Vary: Accept` — a proxy of your own that +`private, no-store` + `Vary: Accept`, while HTML pages keep their caching (ISR unchanged) — a proxy of your own that rewrites to `/md/…` copies the headers (content.md); `markdown: { negotiate: false }` turns negotiation off; (5) CSP report log lines show origins and paths, at most 10 per request and 60 requests per client a minute (a log parser that read full URLs adapts; `createCspReportRoute({ maxReports, rateLimit })`); (6) a text field of your own whose diff --git a/docs/content.md b/docs/content.md index f52746f..ea001cf 100644 --- a/docs/content.md +++ b/docs/content.md @@ -391,7 +391,9 @@ work. The option lets `/md/…` paths through and does the `Accept` negotiation **The negotiated answer is never cached as the page (1.18.0, security audit F3).** It shares the page's URL, so a CDN that caches HTML ("Cache Everything" on Cloudflare, Varnish) would otherwise store the Markdown and serve it to every visitor of that page. The proxy marks the rewritten request, the route answers `private, no-store` with -`Vary: Accept`, the rewrite carries the same headers, and the pages under the proxy matcher get `Vary: Accept`. +`Vary: Accept`, the rewrite carries the same headers. The proxy also asks for `Vary: Accept` on the pages it passes on, but a +Next page answers with Next's own `Vary`: what keeps a shared cache from storing the Markdown as the page is the +`private, no-store` on the Markdown answer. `/md/…` keeps its public caching. Cloudflare ignores `Vary` for HTML — `no-store` is what keeps it out of the cache there. Options: `markdown: { prefix: '/ai', negotiate: false }` — `negotiate: false` serves Markdown only at `/md/…` (no rewrite, no `Vary: Accept` on pages). Verify: diff --git a/reference/.agents/skills/iapl-upgrade/SKILL.md b/reference/.agents/skills/iapl-upgrade/SKILL.md index 7fe2a01..21ecdec 100644 --- a/reference/.agents/skills/iapl-upgrade/SKILL.md +++ b/reference/.agents/skills/iapl-upgrade/SKILL.md @@ -53,7 +53,7 @@ not staff (REST / GraphQL; the Local API and the panel are not touched): a clien 100 documents anonymously gets `hasNextPage: true` — page through, or `listLimit: { max }` / `{ exclude: ['slug'] }` / `false`; (2) a `?sort=$…` answers `400` (`refuseOperatorSort: false` = Payload's way); (3) Payload's document locks are staff only (`lockedDocuments: false` = Payload's default); (4) the negotiated Markdown at a page URL is -`private, no-store` + `Vary: Accept`, and pages under the proxy matcher get `Vary: Accept` — a proxy of your own that +`private, no-store` + `Vary: Accept`, while HTML pages keep their caching (ISR unchanged) — a proxy of your own that rewrites to `/md/…` copies the headers (content.md); `markdown: { negotiate: false }` turns negotiation off; (5) CSP report log lines show origins and paths, at most 10 per request and 60 requests per client a minute (a log parser that read full URLs adapts; `createCspReportRoute({ maxReports, rateLimit })`); (6) a text field of your own whose diff --git a/src/modules/i18n/createProxy.ts b/src/modules/i18n/createProxy.ts index e1f45e4..011b0f8 100644 --- a/src/modules/i18n/createProxy.ts +++ b/src/modules/i18n/createProxy.ts @@ -63,8 +63,8 @@ type CreateProxyOptions = { * redirect — /md/pl/o-nas must not become /pl/md/pl/o-nas), and a page * requested with `Accept: text/markdown` is rewritten to its Markdown version. * - * The negotiated answer shares the page's URL, so it is sent `private, no-store` with `Vary: Accept` (and the - * pages under the matcher get `Vary: Accept`): a cache in front never stores the Markdown as the page (security + * The negotiated answer shares the page's URL, so it is sent `private, no-store` with `Vary: Accept` (the proxy + * also asks for `Vary: Accept` on pages, but a Next page keeps Next's own `Vary`): a cache in front never stores the Markdown as the page (security * audit 2026-12, F3). `/md/…` itself keeps its public caching. The object form adapts it: * `{ prefix?: string, negotiate?: boolean }` — `negotiate: false` serves Markdown only at `/md/…`. */