import { withPayload } from '@payloadcms/next/withPayload' import type { NextConfig } from 'next' import path from 'path' import { fileURLToPath } from 'url' const __filename = fileURLToPath(import.meta.url) const dirname = path.dirname(__filename) const nextConfig: NextConfig = { async headers() { const { buildSecurityHeaders } = await import('@intecion/ipal-kit') return [ { source: '/(.*)', headers: buildSecurityHeaders(), }, ] }, images: { remotePatterns: [ { protocol: 'https', hostname: 'images.unsplash.com', }, ], localPatterns: [ { pathname: '/api/media/file/**', }, ], }, webpack: (webpackConfig) => { webpackConfig.resolve.extensionAlias = { '.cjs': ['.cts', '.cjs'], '.js': ['.ts', '.tsx', '.js', '.jsx'], '.mjs': ['.mts', '.mjs'], } return webpackConfig }, turbopack: { root: path.resolve(dirname), }, } export default withPayload(nextConfig, { devBundleServerPackages: false })