Added fluid skills support
This commit is contained in:
Vendored
+1
-1
@@ -43,7 +43,7 @@ function checkValue(rule: EnvRule, value: string): null | string {
|
||||
|
||||
switch (kind) {
|
||||
case 'boolean':
|
||||
if (!/^(true|false|1|0|yes|no)$/i.test(value)) {
|
||||
if (!/^(?:true|false|1|0|yes|no)$/i.test(value)) {
|
||||
return `${name} must be a boolean (true/false/1/0/yes/no, got "${value}")`
|
||||
}
|
||||
break
|
||||
|
||||
Vendored
+15
-6
@@ -53,11 +53,7 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
|
||||
const rules: EnvRule[] = [
|
||||
{ name: databaseVar, description: 'Database connection string (e.g. MongoDB URI)' },
|
||||
{ name: secretVar, description: 'Payload secret used to sign tokens' },
|
||||
{
|
||||
name: serverUrlVar,
|
||||
description: 'Public site origin, e.g. https://example.com',
|
||||
kind: 'url',
|
||||
},
|
||||
{ name: serverUrlVar, description: 'Public site origin, e.g. https://example.com', kind: 'url' },
|
||||
{
|
||||
name: 'NODE_ENV',
|
||||
description: 'Node environment',
|
||||
@@ -72,7 +68,20 @@ export function ipalEnvRules(features: IpalEnvFeatures = {}): EnvRule[] {
|
||||
{ name: 'R2_ACCESS_KEY_ID', description: 'R2 access key id' },
|
||||
{ name: 'R2_SECRET_ACCESS_KEY', description: 'R2 secret access key' },
|
||||
{ name: 'R2_ENDPOINT', description: 'R2 S3 API endpoint URL', kind: 'url' },
|
||||
{ name: 'R2_PUBLIC_URL', description: 'Public base URL media is served from', kind: 'url' },
|
||||
{
|
||||
name: 'R2_PUBLIC_URL',
|
||||
description: 'Public base URL media is served from (custom domain of the bucket)',
|
||||
// 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).
|
||||
validate: (v) => {
|
||||
if (/^https?:\/\/[^/\s]+/i.test(v)) {return true}
|
||||
if (v.startsWith('/') && process.env.NODE_ENV !== 'production') {return true}
|
||||
return v.startsWith('/')
|
||||
? `R2_PUBLIC_URL must be an absolute URL in production (got "${v}") — e.g. https://media.example.com`
|
||||
: `R2_PUBLIC_URL must be an absolute URL (https://…) or, outside production, a path starting with "/" (got "${v}")`
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ export function buildCsp(args: BuildCspArgs = {}): { key: string; value: string
|
||||
'object-src': ["'none'"], // block <object>/<embed> (Flash-era attack surface)
|
||||
}
|
||||
|
||||
if (r2Url) {src['img-src'].push(r2Url)}
|
||||
// Site-relative R2_PUBLIC_URL ('/media', dev) is same-origin — already covered by 'self'.
|
||||
if (r2Url && /^https?:\/\//i.test(r2Url)) {src['img-src'].push(r2Url)}
|
||||
|
||||
if (turnstile) {
|
||||
src['script-src'].push('https://challenges.cloudflare.com')
|
||||
@@ -110,7 +111,6 @@ export function buildCsp(args: BuildCspArgs = {}): { key: string; value: string
|
||||
.map(([dir, values]) => `${dir} ${values.join(' ')}`)
|
||||
.join('; ')
|
||||
|
||||
const key =
|
||||
mode === 'report-only' ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'
|
||||
const key = mode === 'report-only' ? 'Content-Security-Policy-Report-Only' : 'Content-Security-Policy'
|
||||
return { key, value }
|
||||
}
|
||||
|
||||
@@ -89,13 +89,15 @@ export type SitemapRouteOptions = {
|
||||
export function createSitemapRouteHandler(
|
||||
sitemap: () => Promise<SitemapEntry[]>,
|
||||
opts: SitemapRouteOptions = {},
|
||||
): (req?: Request) => Promise<Response> {
|
||||
): (req: Request) => Promise<Response> {
|
||||
const style = opts.cssUrl ? false : opts.style === false ? false : (opts.style ?? {})
|
||||
|
||||
return async (req?: Request) => {
|
||||
const url = req ? new URL(req.url) : null
|
||||
// `req` is required: Next 16 type-checks the first argument of a route handler
|
||||
// (`Request | undefined` fails the build). A zero-argument call is not supported.
|
||||
return async (req: Request) => {
|
||||
const url = new URL(req.url)
|
||||
|
||||
if (style && url?.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
||||
if (style && url.searchParams.has(SITEMAP_STYLE_PARAM)) {
|
||||
let title: string | undefined
|
||||
try {
|
||||
title = typeof style.title === 'function' ? await style.title() : style.title
|
||||
@@ -111,7 +113,7 @@ export function createSitemapRouteHandler(
|
||||
})
|
||||
}
|
||||
|
||||
const cssUrl = opts.cssUrl ?? (style ? `${url?.pathname ?? '/sitemap.xml'}?${SITEMAP_STYLE_PARAM}` : undefined)
|
||||
const cssUrl = opts.cssUrl ?? (style ? `${url.pathname}?${SITEMAP_STYLE_PARAM}` : undefined)
|
||||
try {
|
||||
const entries = await sitemap()
|
||||
const xml = buildSitemapXml(entries, { cssUrl })
|
||||
|
||||
@@ -77,7 +77,12 @@ export const buildR2Storage = (
|
||||
// (media.klient.pl → bucket) set R2_PUBLIC_URL so Payload generates URLs
|
||||
// pointing there. Without it, uploads work but images don't display publicly.
|
||||
// See docs/storage.md.
|
||||
const publicUrl = process.env.R2_PUBLIC_URL?.replace(/\/$/, '') // strip trailing slash
|
||||
// Site-relative value ('/media', dev only — ipalEnvRules rejects it in production)
|
||||
// → prefixed with NEXT_PUBLIC_SERVER_URL so Payload still stores absolute URLs.
|
||||
const rawPublicUrl = process.env.R2_PUBLIC_URL?.trim().replace(/\/$/, '') // strip trailing slash
|
||||
const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL?.trim().replace(/\/$/, '')
|
||||
const publicUrl =
|
||||
rawPublicUrl?.startsWith('/') && serverUrl ? `${serverUrl}${rawPublicUrl}` : rawPublicUrl
|
||||
|
||||
// generateFileURL is a PER-COLLECTION option in @payloadcms/storage-s3 (not a
|
||||
// top-level one) — R2 needs it to point served URLs at the custom domain
|
||||
|
||||
Reference in New Issue
Block a user