Small fixes: optional R2_PUBLIC_URL, seo.uploadsCollection, staff features without roles

- ipalEnvRules({ storage: true }): R2_PUBLIC_URL optional (media served by
  the app); storage: { requirePublicUrl: true } requires it again.
- seo.uploadsCollection: upload collection of the meta image (default media).
- userMeetsRole(req, minimum): the plugin's admin/editor features (Site
  Integrations, settings globals, test e-mail, stats, consent records, form
  submissions) stay reachable when `access` is omitted — without a roles
  field every logged-in account passes, as in Payload's default.
- IndexNow skip for seed writes is covered by test/seed.test.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-10-22 18:33:35 +02:00
co-authored by Claude Opus 5.5
parent cff76c2a69
commit 4911da7112
24 changed files with 167 additions and 68 deletions
+11 -13
View File
@@ -59,7 +59,7 @@ use).
```ts
ipalEnvRules({
storage?: boolean, // R2_* (R2_BUCKET, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_ENDPOINT, R2_PUBLIC_URL)
storage?: boolean | { requirePublicUrl?: boolean }, // R2_* (R2_BUCKET, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_ENDPOINT; R2_PUBLIC_URL optional)
emailGraph?: boolean, // GRAPH_* (GRAPH_TENANT_ID, GRAPH_CLIENT_ID, GRAPH_CLIENT_SECRET, GRAPH_SENDER — e-mail)
ipHeader?: boolean, // IPAL_IP_HEADER — required in production, optional outside it (header name [a-z0-9-])
turnstile?: boolean | { siteKeyVar?: string; secretVar?: string }, // NEXT_PUBLIC_TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY
@@ -75,11 +75,13 @@ Always (core): `DATABASE_URI`, `PAYLOAD_SECRET`, `NEXT_PUBLIC_SERVER_URL` (URL),
read; DB/secret are Payload variables — their names can be overridden.
**`storage: true` — when R2_* are required** (evaluated when `ipalEnvRules` is called):
- `NODE_ENV=production` → all 5 (`R2_PUBLIC_URL` as an absolute URL);
- outside production, when any of the 4 keys is set (`R2_BUCKET`, `R2_ACCESS_KEY_ID`,
`R2_SECRET_ACCESS_KEY`, `R2_ENDPOINT`) → all 5 (all or none);
- `NODE_ENV=production` → the 4 keys (`R2_BUCKET`, `R2_ACCESS_KEY_ID`, `R2_SECRET_ACCESS_KEY`, `R2_ENDPOINT`);
- outside production, when any of the 4 keys is set → all 4 (all or none);
- outside production without keys → none required (local disk); `R2_PUBLIC_URL` alone passes
(read-only mode, storage.md).
- `R2_PUBLIC_URL` is **optional**: empty = media served by the app. When set, it must be an absolute URL in
production. `storage: { requirePublicUrl: true }` requires it wherever the 4 keys are required (a project
that always uses a media domain).
**`turnstile: true`** makes both Turnstile variables **required**, even though the plugin takes the keys
from the panel first (Site Integrations) and env is only a fallback — turn it on only when you keep the keys
@@ -154,17 +156,13 @@ import type { EnvRule, EnvKind, AssertEnvOptions, IpalEnvFeatures } from '@intec
## `R2_PUBLIC_URL` — production vs dev
`ipalEnvRules({ storage: true })` requires a full URL in **production**
(`https://media.klient-media.com`). Our default, though, is media served through the app with
`R2_PUBLIC_URL` **empty** (the client zones are not on Cloudflare — storage.md, deployment.md §6) — then make the
rule optional (the URL format is still checked when set):
`R2_PUBLIC_URL` is optional in `ipalEnvRules({ storage: true })`: our default is media served through the app
with `R2_PUBLIC_URL` **empty** (the client zones are not on Cloudflare — storage.md, deployment.md §6). When it is
set, **production** requires a full URL (`https://media.klient-media.com`). A project that always uses a media
domain requires it:
```ts
assertEnv(
ipalEnvRules({ storage: true, ipHeader: true }).map((r) =>
r.name === 'R2_PUBLIC_URL' ? { ...r, required: false } : r,
),
)
assertEnv(ipalEnvRules({ storage: { requirePublicUrl: true }, ipHeader: true }))
```
Outside production it allows a relative path