mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
83 lines
2.6 KiB
TypeScript
83 lines
2.6 KiB
TypeScript
import type { NextConfig } from 'next'
|
|
|
|
// Check if we're building for standalone distribution
|
|
const isStandaloneBuild = process.env.USE_LOCAL_STORAGE === 'true'
|
|
|
|
const nextConfig: NextConfig = {
|
|
devIndicators: false,
|
|
images: {
|
|
domains: ['avatars.githubusercontent.com'],
|
|
// Enable static image optimization for standalone export
|
|
unoptimized: isStandaloneBuild,
|
|
},
|
|
// Always use 'standalone' output to support API routes
|
|
output: 'standalone',
|
|
webpack: (config, { isServer }) => {
|
|
// Configure webpack to use memory cache instead of filesystem cache
|
|
// This avoids the serialization of large strings during the build process
|
|
if (config.cache) {
|
|
config.cache = {
|
|
type: 'memory',
|
|
maxGenerations: 1,
|
|
}
|
|
}
|
|
|
|
return config
|
|
},
|
|
// Only include headers when not building for standalone export
|
|
...(isStandaloneBuild
|
|
? {}
|
|
: {
|
|
async headers() {
|
|
return [
|
|
{
|
|
// API routes CORS headers
|
|
source: '/api/:path*',
|
|
headers: [
|
|
{ key: 'Access-Control-Allow-Credentials', value: 'true' },
|
|
{
|
|
key: 'Access-Control-Allow-Origin',
|
|
value: 'https://localhost:3001',
|
|
},
|
|
{
|
|
key: 'Access-Control-Allow-Methods',
|
|
value: 'GET,POST,OPTIONS,PUT,DELETE',
|
|
},
|
|
{
|
|
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',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
// Apply Cross-Origin Isolation headers to all routes except those that use the Google Drive Picker
|
|
source: '/((?!w/.*|api/auth/oauth/drive).*)',
|
|
headers: [
|
|
{
|
|
key: 'Cross-Origin-Embedder-Policy',
|
|
value: 'require-corp',
|
|
},
|
|
{
|
|
key: 'Cross-Origin-Opener-Policy',
|
|
value: 'same-origin',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
// For routes that use the Google Drive Picker, only apply COOP but not COEP
|
|
source: '/(w/.*|api/auth/oauth/drive)',
|
|
headers: [
|
|
{
|
|
key: 'Cross-Origin-Opener-Policy',
|
|
value: 'same-origin',
|
|
},
|
|
],
|
|
},
|
|
]
|
|
},
|
|
}),
|
|
}
|
|
|
|
export default nextConfig
|