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
+12 -7
View File
@@ -17,12 +17,16 @@ export type IpalEnvFeatures = {
/** Override the site-URL var. Default 'NEXT_PUBLIC_SERVER_URL'. */
serverUrlVar?: string
/**
* R2 object storage (buildR2Storage). Adds the R2_* vars — required in
* production (media on a container disk vanish on redeploy). Outside
* production they're optional (media go to the local disk), but a partial
* set is an error: buildR2Storage needs all of them.
* R2 object storage (buildR2Storage). Adds the R2_* vars — the credentials
* are required in production (media on a container disk vanish on redeploy).
* Outside production they're optional (media go to the local disk), but a
* partial set is an error: buildR2Storage needs all of them.
*
* R2_PUBLIC_URL is optional: empty = media served by the app
* (/api/media/file/…). `{ requirePublicUrl: true }` requires it wherever the
* credentials are required (a media domain on Cloudflare).
*/
storage?: boolean
storage?: { requirePublicUrl?: boolean } | boolean
/**
* Cloudflare Turnstile. true uses the common var names
* (NEXT_PUBLIC_TURNSTILE_SITE_KEY + TURNSTILE_SECRET_KEY); pass an object to
@@ -74,6 +78,7 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
]
if (storage) {
const requirePublicUrl = typeof storage === 'object' && storage.requirePublicUrl === true
const r2Credentials = ['R2_BUCKET', 'R2_ACCESS_KEY_ID', 'R2_SECRET_ACCESS_KEY', 'R2_ENDPOINT']
// Production: always. Development: once any credential is set (all or nothing).
// R2_PUBLIC_URL alone is the read-only media mode (buildR2Storage) — allowed in dev.
@@ -86,8 +91,8 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
{ name: 'R2_ENDPOINT', description: 'R2 S3 API endpoint URL', kind: 'url', required: r2Required },
{
name: 'R2_PUBLIC_URL',
description: 'Public base URL media is served from (custom domain of the bucket)',
required: r2Required,
description: 'Public base URL media is served from (custom domain of the bucket); empty = served by the app',
required: requirePublicUrl && r2Required,
// Production: absolute URL (https://media.example.com). Outside production a
// site-relative path ('/media') is accepted — buildR2Storage prefixes it with
// NEXT_PUBLIC_SERVER_URL (e.g. a dev rewrite /media → bucket).