-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathnext.config.ts
More file actions
141 lines (126 loc) · 3.18 KB
/
next.config.ts
File metadata and controls
141 lines (126 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import type { NextConfig } from 'next';
/** @type {import('next').NextConfig} */
const nextConfig: NextConfig = {
// Enable Turbopack for development
turbopack: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
devIndicators: {
position: 'bottom-right',
},
// SASS configuration
sassOptions: {
includePaths: ['./app/styles'],
},
// Enable TypeScript
typescript: {
/*
* !! WARN !!
* Dangerously allow production builds to successfully complete even if
* your project has type errors.
* !! WARN !!
*/
ignoreBuildErrors: true,
},
// Enable ESLint
eslint: {
/*
* Warning: This allows production builds to successfully complete even if
* your project has ESLint errors.
*/
ignoreDuringBuilds: true,
},
// Webpack configuration for production builds only
webpack: (config, { isServer, dev }) => {
// Only apply webpack configuration for production builds
if (!dev) {
// Node polyfills for client-side
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
net: false,
tls: false,
crypto: false,
stream: false,
url: false,
zlib: false,
http: false,
https: false,
assert: false,
os: false,
path: false,
buffer: 'buffer',
process: 'process/browser',
util: 'util',
};
}
config.cache = true;
}
// Add SVG handling for both development and production
config.module.rules.push({
test: /\.svg$/,
use: ['@svgr/webpack'],
});
return config;
},
// Image optimization
images: {
domains: ['localhost'],
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
// Environment variables
env: {
CUSTOM_KEY: process.env.CUSTOM_KEY,
},
// Redirects and rewrites
async redirects() {
return [
// Add any redirects here
];
},
async rewrites() {
return [
// Add any rewrites here
];
},
// Headers
async headers() {
const headers = [
{
source: '/((?!api/).*)',
headers: [
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'origin-when-cross-origin' },
{ key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
{ key: 'Cross-Origin-Embedder-Policy', value: 'require-corp' },
],
},
];
// Permissive CORS for all API routes only in local environment (Cloudflared quick tunnels)
if (process.env.NEXT_PUBLIC_ENV_NAME === 'local') {
headers.push({
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Origin', value: '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET, POST, PUT, DELETE, OPTIONS' },
{ key: 'Access-Control-Allow-Headers', value: '*' },
{ key: 'Access-Control-Expose-Headers', value: '*' },
],
});
}
return headers;
},
};
export default nextConfig;