Files
metabuilder/frontends/nextjs/next.config.ts
copilot-swe-agent[bot] 5491597a79 fix: improve AWS SDK optional import handling
- Added @ts-ignore for optional AWS SDK import to prevent TypeScript errors
- Changed webpack config to use resolve.fallback instead of externals
- Improved error message for missing AWS SDK
- Made S3 storage truly optional with better runtime error handling

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-27 13:57:46 +00:00

105 lines
2.8 KiB
TypeScript

import type { NextConfig } from 'next'
import path from 'path'
const nextConfig: NextConfig = {
reactStrictMode: true,
// Standalone output for Docker
output: 'standalone',
// Configure page extensions
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
// Experimental features
experimental: {
// Enable React Server Components
serverActions: {
bodySizeLimit: '2mb',
allowedOrigins: ['localhost:3000'],
},
// Optimize package imports
optimizePackageImports: [
'@mui/material',
'@mui/icons-material',
'@mui/x-data-grid',
'@mui/x-date-pickers',
'recharts',
'd3',
],
},
// Image optimization configuration
images: {
formats: ['image/avif', 'image/webp'],
dangerouslyAllowSVG: true,
contentDispositionType: 'attachment',
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
remotePatterns: [
{
protocol: 'https',
hostname: 'avatars.githubusercontent.com',
},
{
protocol: 'https',
hostname: '**.githubusercontent.com',
},
],
},
// Turbopack configuration (empty for now, migrations from webpack can be added later)
turbopack: {},
// Redirects for old routes (if needed)
async redirects() {
return []
},
// Headers for security and CORS
async headers() {
return [
{
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET,DELETE,PATCH,POST,PUT' },
{ key: 'Access-Control-Allow-Headers', value: 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version' },
],
},
]
},
// TypeScript configuration
typescript: {
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
ignoreBuildErrors: false,
},
// Environment variables exposed to browser
env: {
NEXT_PUBLIC_DBAL_API_URL: process.env.DBAL_API_URL || 'http://localhost:8080',
NEXT_PUBLIC_DBAL_WS_URL: process.env.DBAL_WS_URL || 'ws://localhost:50051',
NEXT_PUBLIC_DBAL_API_KEY: process.env.DBAL_API_KEY || '',
},
webpack(config, { isServer }) {
config.resolve.alias = {
...config.resolve.alias,
'@/dbal': path.resolve(__dirname, '../../dbal/development/src'),
'@dbal-ui': path.resolve(__dirname, '../../dbal/shared/ui'),
}
// Ignore optional AWS SDK on client side
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
'@aws-sdk/client-s3': false,
}
}
return config
},
}
export default nextConfig