import { withPayload } from '@payloadcms/next/withPayload' import type { NextConfig } from 'next' import createNextIntlPlugin from 'next-intl/plugin' import path from 'node:path' import { fileURLToPath } from 'node:url' const dirname = path.dirname(fileURLToPath(import.meta.url)) const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts') const nextConfig: NextConfig = { // dev открывается через nginx на доменах dev.*, без этого Next не отдаёт им ресурсы dev-сервера allowedDevOrigins: (process.env.DEV_ALLOWED_ORIGINS ?? '').split(',').filter(Boolean), poweredByHeader: false, // proxy получает адрес запроса таким, каким его видит роутер Next. Иначе адрес строится // от localhost, а роутер слушает 127.0.0.1, и любое переписывание считается внешним skipProxyUrlNormalize: true, turbopack: { root: dirname, }, webpack: (webpackConfig) => { webpackConfig.resolve.extensionAlias = { '.cjs': ['.cts', '.cjs'], '.js': ['.ts', '.tsx', '.js', '.jsx'], '.mjs': ['.mts', '.mjs'], } return webpackConfig }, } export default withPayload(withNextIntl(nextConfig), { devBundleServerPackages: false })