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
+2 -9
View File
@@ -98,15 +98,8 @@ Requirements and consequences:
- **Public read on the upload collection** — the file route checks the collection's `read` access, and Payload's
default is "logged-in users only" → anonymous visitors (and next/image) get 403. Add
`access: { read: () => true }` to `Media` (and every other public upload collection).
- **Env validation** — `ipalEnvRules({ storage: true })` requires `R2_PUBLIC_URL` in production; make it optional:
```ts
assertEnv(
ipalEnvRules({ storage: true, ipHeader: true }).map((r) =>
r.name === 'R2_PUBLIC_URL' ? { ...r, required: false } : r,
),
)
```
- **Env validation** — nothing to change: `ipalEnvRules({ storage: true })` treats `R2_PUBLIC_URL` as optional
(`storage: { requirePublicUrl: true }` makes it required, for projects that always use a media domain).
- next/image treats the URLs as local images; CSP `img-src 'self'` already covers them; `MediaPreconnect` renders
nothing (same origin); the plugin's sitemap / JSON-LD helpers make relative image URLs absolute.
- Cost: every original file request passes through the app (bandwidth/CPU). Page images go through `/_next/image`,