cms.c2sgmbh/src/payload.config.ts
Martin Porwoll 85b7ddd7bd fix(admin): disable all custom components due to path-to-regexp bug
TenantBreadcrumb in afterNavLinks also triggers the error on production.
Completely disabling admin.components until Payload fixes the issue.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-20 15:07:32 +00:00

345 lines
10 KiB
TypeScript

import { buildConfig } from 'payload'
import { postgresAdapter } from '@payloadcms/db-postgres'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import { multiTenantPlugin } from '@payloadcms/plugin-multi-tenant'
import { seoPlugin } from '@payloadcms/plugin-seo'
import { nestedDocsPlugin } from '@payloadcms/plugin-nested-docs'
import { formBuilderPlugin } from '@payloadcms/plugin-form-builder'
import { redirectsPlugin } from '@payloadcms/plugin-redirects'
import { openapi, swaggerUI } from 'payload-oapi'
import { de } from '@payloadcms/translations/languages/de'
import { en } from '@payloadcms/translations/languages/en'
import path from 'path'
import { fileURLToPath } from 'url'
import sharp from 'sharp'
// Security: Validate required environment variables at startup
import { env } from './lib/envValidation'
import { Users } from './collections/Users'
import { Media } from './collections/Media'
import { Tenants } from './collections/Tenants'
import { Pages } from './collections/Pages'
import { Posts } from './collections/Posts'
import { Categories } from './collections/Categories'
import { SocialLinks } from './collections/SocialLinks'
import { Testimonials } from './collections/Testimonials'
import { FAQs } from './collections/FAQs'
import { Team } from './collections/Team'
import { ServiceCategories } from './collections/ServiceCategories'
import { Services } from './collections/Services'
import { NewsletterSubscribers } from './collections/NewsletterSubscribers'
// Portfolio Collections
import { PortfolioCategories } from './collections/PortfolioCategories'
import { Portfolios } from './collections/Portfolios'
// Video Collections
import { VideoCategories } from './collections/VideoCategories'
import { Videos } from './collections/Videos'
// Product Collections
import { ProductCategories } from './collections/ProductCategories'
import { Products } from './collections/Products'
// Timeline Collection
import { Timelines } from './collections/Timelines'
// Workflow Collection
import { Workflows } from './collections/Workflows'
// Blogging Collections
import { Tags } from './collections/Tags'
import { Authors } from './collections/Authors'
// New Feature Collections
import { Locations } from './collections/Locations'
import { Partners } from './collections/Partners'
import { Jobs } from './collections/Jobs'
import { Downloads } from './collections/Downloads'
import { Events } from './collections/Events'
// Tenant-specific Collections
import { Bookings } from './collections/Bookings'
import { Certifications } from './collections/Certifications'
import { Projects } from './collections/Projects'
// Consent Management Collections
import { CookieConfigurations } from './collections/CookieConfigurations'
import { CookieInventory } from './collections/CookieInventory'
import { ConsentLogs } from './collections/ConsentLogs'
import { PrivacyPolicySettings } from './collections/PrivacyPolicySettings'
import { SiteSettings } from './globals/SiteSettings'
import { Navigation } from './globals/Navigation'
import { SEOSettings } from './globals/SEOSettings'
// Hooks
import { sendFormNotification } from './hooks/sendFormNotification'
import { formSubmissionBeforeChange } from './hooks/formSubmissionHooks'
// Form Submissions Overrides
import { formSubmissionOverrides } from './collections/FormSubmissionsOverrides'
// Email
import { multiTenantEmailAdapter } from './lib/email/payload-email-adapter'
// Email Logs
import { EmailLogs } from './collections/EmailLogs'
// Audit Logs
import { AuditLogs } from './collections/AuditLogs'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
serverURL: process.env.PAYLOAD_PUBLIC_SERVER_URL || 'https://pl.porwoll.tech',
admin: {
user: Users.slug,
// All custom components disabled due to path-to-regexp bug
// See BUG_REPORT_CUSTOM_VIEWS.md for details
// TypeError: Missing parameter name at 5
// components: {
// afterNavLinks: ['@/components/admin/TenantBreadcrumb#TenantBreadcrumb'],
// views: {
// TenantDashboard: {
// Component: '@/components/admin/TenantDashboardView#TenantDashboardView',
// path: '/tenant-dashboard',
// },
// },
// beforeNavLinks: ['@/components/admin/DashboardNavLink#DashboardNavLink'],
// },
},
// Multi-Tenant Email Adapter
email: multiTenantEmailAdapter,
// Admin Panel Internationalization (UI translations)
i18n: {
supportedLanguages: { de, en },
fallbackLanguage: 'de',
},
// Content Localization (multilingual content)
localization: {
locales: [
{
label: 'Deutsch',
code: 'de',
},
{
label: 'English',
code: 'en',
},
],
defaultLocale: 'de',
fallback: true,
},
// CORS Konfiguration für externe Frontends
cors: [
'http://localhost:3000',
'http://localhost:3001',
'http://10.10.180.153:3000',
'http://10.10.180.153:3001',
'https://dev.zh3.de',
'https://porwoll.de',
'https://www.porwoll.de',
'https://pl.porwoll.tech',
],
// CSRF Protection
csrf: [
'http://localhost:3000',
'http://localhost:3001',
'http://10.10.180.153:3000',
'http://10.10.180.153:3001',
'https://dev.zh3.de',
'https://porwoll.de',
'https://www.porwoll.de',
'https://pl.porwoll.tech',
],
collections: [
Users,
Media,
Tenants,
Pages,
Posts,
Categories,
SocialLinks,
Testimonials,
FAQs,
Team,
ServiceCategories,
Services,
NewsletterSubscribers,
// Portfolio
PortfolioCategories,
Portfolios,
// Videos
VideoCategories,
Videos,
// Products
ProductCategories,
Products,
// Timelines & Workflows
Timelines,
Workflows,
// Blogging
Tags,
Authors,
// New Feature Collections
Locations,
Partners,
Jobs,
Downloads,
Events,
// Tenant-specific Collections
Bookings,
Certifications,
Projects,
// Consent Management
CookieConfigurations,
CookieInventory,
ConsentLogs,
PrivacyPolicySettings,
// System
EmailLogs,
AuditLogs,
],
globals: [SiteSettings, Navigation, SEOSettings],
editor: lexicalEditor(),
secret: env.PAYLOAD_SECRET,
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: postgresAdapter({
pool: {
connectionString: env.DATABASE_URI,
},
// push: false - Schema-Änderungen nur via Migrationen
push: false,
}),
// Sharp für Bildoptimierung
sharp,
plugins: [
multiTenantPlugin({
tenantsSlug: 'tenants',
collections: {
media: {},
pages: {},
posts: {},
categories: {},
'social-links': {},
// Type assertion für neue Collections bis payload-types.ts regeneriert wird
...({
testimonials: {},
faqs: {},
team: {},
'service-categories': {},
services: {},
'newsletter-subscribers': {},
// Portfolio Collections
'portfolio-categories': {},
portfolios: {},
// Video Collections
'video-categories': {},
videos: {},
// Product Collections
'product-categories': {},
products: {},
// Timeline & Workflow Collections
timelines: {},
workflows: {},
// Blogging Collections
tags: {},
authors: {},
// New Feature Collections
locations: {},
partners: {},
jobs: {},
downloads: {},
events: {},
// Tenant-specific Collections
bookings: {},
certifications: {},
projects: {},
// Consent Management Collections - customTenantField: true weil sie bereits ein tenant-Feld haben
'cookie-configurations': { customTenantField: true },
'cookie-inventory': { customTenantField: true },
'consent-logs': { customTenantField: true },
'privacy-policy-settings': { customTenantField: true },
} as Record<string, { customTenantField?: boolean }>),
},
// Super Admins haben Zugriff auf alle Tenants
userHasAccessToAllTenants: (user) => Boolean(user?.isSuperAdmin),
debug: true,
// Deutsche Übersetzungen für den Tenant-Selector
i18n: {
translations: {
de: {
'nav-tenantSelector-label': 'Nach Tenant filtern',
'assign-tenant-button-label': 'Tenant zuweisen',
'assign-tenant-modal-title': '"{{title}}" zuweisen',
'field-assignedTenant-label': 'Zugewiesener Tenant',
},
en: {
'nav-tenantSelector-label': 'Filter by Tenant',
'assign-tenant-button-label': 'Assign Tenant',
'assign-tenant-modal-title': 'Assign "{{title}}"',
'field-assignedTenant-label': 'Assigned Tenant',
},
},
},
}),
seoPlugin({
collections: [],
uploadsCollection: 'media',
generateTitle: ({ doc }) => `${doc?.title || ''} | Website`,
generateDescription: ({ doc }) => doc?.excerpt || '',
}),
nestedDocsPlugin({
collections: [],
generateLabel: (_, doc) => doc.title as string,
generateURL: (docs) => docs.reduce((url, doc) => `${url}/${doc.slug}`, ''),
}),
formBuilderPlugin({
fields: {
text: true,
textarea: true,
select: true,
email: true,
state: false,
country: false,
checkbox: true,
number: true,
message: true,
payment: false,
},
// Fix für TypeScript Types Generation - das Plugin braucht explizite relationTo Angaben
redirectRelationships: ['pages'],
formSubmissionOverrides: {
...(formSubmissionOverrides as Record<string, unknown>),
hooks: {
beforeChange: [formSubmissionBeforeChange],
afterChange: [sendFormNotification],
},
} as Parameters<typeof formBuilderPlugin>[0]['formSubmissionOverrides'],
}),
redirectsPlugin({
collections: ['pages'],
overrides: {
admin: {
group: 'Einstellungen',
},
},
}),
// OpenAPI Documentation
openapi({
openapiVersion: '3.1',
metadata: {
title: 'Payload CMS API',
version: '1.0.0',
description: 'Multi-Tenant CMS API für porwoll.de, complexcaresolutions.de, gunshin.de und zweitmein.ng',
},
}),
// Swagger UI unter /api/docs
swaggerUI({}),
],
})