-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
98 lines (90 loc) · 2.17 KB
/
next.config.js
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
// Load environment variables
require('./loadEnv');
const compress = process.env.NEXT_COMPRESS
? process.env.NEXT_COMPRESS === 'true'
: true;
const assetPrefix = process.env.NEXT_PUBLIC_CDN_URL || '';
const buildId = process.env.NEXT_PUBLIC_BUILD_ID || null;
const customDomainName = process.env.SERVICE_WEB_CUSTOM_DOMAIN_NAME || '';
const remotePatterns = [];
const headers = [];
const rewrites = {};
const redirects = [];
if (assetPrefix) {
// Allow the Image component to load images from the CDN
remotePatterns.push({
protocol: 'https',
hostname: process.env.NEXT_PUBLIC_CDN_HOSTNAME,
});
}
if (buildId) {
// If the `buildId` is present in the path, remove it
rewrites.beforeFiles = [
{
source: `/${buildId}/:path*`,
destination: '/:path*',
},
];
// Also add a cache control header as these resources are immutable for each build
headers.push({
source: `/${buildId}/:path*`,
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
});
}
if (customDomainName) {
// Add a canonical host name redirect
redirects.push({
source: '/:path*',
missing: [
{
type: 'host',
value: customDomainName,
},
],
destination: `https://${customDomainName}/:path*`,
permanent: true,
});
}
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
instrumentationHook: true,
serverComponentsExternalPackages: ['applicationinsights', 'pino'],
},
output: 'standalone',
reactStrictMode: true,
poweredByHeader: false,
eslint: {
ignoreDuringBuilds: true,
},
compress,
assetPrefix,
generateBuildId: async () => {
return buildId;
},
images: {
remotePatterns,
},
async headers() {
return headers;
},
async rewrites() {
return rewrites;
},
async redirects() {
return redirects;
},
env: {
PINECONE_API_KEY: process.env.PINECONE_API_KEY,
PINECONE_REGION: process.env.PINECONE_REGION,
PINECONE_CLOUD: process.env.PINECONE_CLOUD,
PINECONE_INDEX: process.env.PINECONE_INDEX,
PINECONE_NAMESPACE: process.env.PINECONE_NAMESPACE,
},
};
module.exports = nextConfig;