-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
122 lines (118 loc) · 3.57 KB
/
next.config.js
File metadata and controls
122 lines (118 loc) · 3.57 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
const dotenv = require('dotenv');
const path = require('path');
const { existsSync } = require('fs');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
module.exports = withBundleAnalyzer({
// Move env loading to the top level, outside the config
...loadEnv(),
i18n: {
locales: ['en', 'ru', 'hy'],
defaultLocale: 'en',
},
async rewrites() {
return [
// Legacy prefix strip — both repos used to namespace public/ with
// /keepsimple_/* and /uxcore_/* respectively. Public is now flat, so any
// straggler path with those prefixes resolves to the bare equivalent.
{ source: '/keepsimple_/:path*', destination: '/:path*' },
{ source: '/uxcore_/:path*', destination: '/:path*' },
];
},
async headers() {
const isDev = process.env.NODE_ENV !== 'production';
const scriptSrc = [
"'self'",
"'unsafe-inline'",
// Next.js dev mode (Fast Refresh) requires eval.
isDev ? "'unsafe-eval'" : '',
'https://analytics.ahrefs.com',
'https://www.googletagmanager.com',
'https://www.google-analytics.com',
'https://cdn.mxpnl.com',
]
.filter(Boolean)
.join(' ');
const connectSrc = [
"'self'",
// Next.js dev HMR uses ws:// to localhost.
isDev ? 'ws:' : '',
'https://*.keepsimple.io',
'https://metrics.administration.ae',
'https://api.mixpanel.com',
'https://www.google-analytics.com',
]
.filter(Boolean)
.join(' ');
return [
{
source: '/:path*',
headers: [
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'X-Frame-Options', value: 'DENY' },
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()',
},
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
`script-src ${scriptSrc}`,
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob: https://lh3.googleusercontent.com https://cdn.discordapp.com https://strapi.keepsimple.io https://staging-strapi.keepsimple.io https://www.google-analytics.com",
"font-src 'self' data:",
`connect-src ${connectSrc}`,
"frame-ancestors 'none'",
"base-uri 'self'",
"form-action 'self'",
].join('; '),
},
],
},
];
},
env: {
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
},
compiler: {
removeConsole: process.env.NODE_ENV === 'prod',
},
eslint: {
ignoreDuringBuilds: true,
},
images: {
domains: [
'lh3.googleusercontent.com',
'cdn.discordapp.com',
'strapi.keepsimple.io',
'staging-strapi.keepsimple.io',
],
deviceSizes: [480, 640, 750, 828, 1080, 1200, 1920, 2048, 3840],
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
});
return config;
},
productionBrowserSourceMaps: true,
});
function loadEnv() {
const envFile = `.env.${process.env.APP_ENV || 'local'}`;
const envPath = path.join(__dirname, envFile);
if (existsSync(envPath)) {
dotenv.config({ path: envPath });
} else {
console.error(`Env file not found: ${envPath}`);
}
return {};
}