import type { AllowList } from 'payload' /** * Paste-URL allow list for upload fields (media / files / videos). * * Configure via the NEXT_PUBLIC_PASTE_URL_ALLOW_LIST environment variable: * - Comma-separated hostnames, e.g. "www.eversolo.com,am.luxsinaudio.com" * - Bare hostnames default to https; you may also pass full "protocol://host" entries. * - When the variable is unset or empty, the built-in defaults below are used. * * NOTE: NEXT_PUBLIC_ prefix is required so the client-side fetch interceptor * can also read this value at build time. */ const DEFAULT_HOSTS = ['www.eversolo.com', 'eversolo.com', 'am.luxsinaudio.com'] function buildAllowList(): AllowList { const raw = (process.env.NEXT_PUBLIC_PASTE_URL_ALLOW_LIST || '').trim() const entries = raw ? raw.split(',').map((item) => item.trim()).filter(Boolean) : DEFAULT_HOSTS return entries.map((entry) => { if (/^https?:\/\//i.test(entry)) { const url = new URL(entry) return { hostname: url.hostname, protocol: url.protocol.replace(':', '') as 'http' | 'https' } } return { hostname: entry, protocol: 'https' as const } }) } export const eversoloPasteURLAllowList: AllowList = buildAllowList()