-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.js
More file actions
executable file
·93 lines (87 loc) · 1.99 KB
/
next.config.js
File metadata and controls
executable file
·93 lines (87 loc) · 1.99 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
const CircularDependencyPlugin = require('circular-dependency-plugin');
const withPWA = require('next-pwa')({
dest: 'public',
disable: process.env.NODE_ENV !== 'production',
});
const runtimeCaching = require('next-pwa/cache');
const plugins = [];
// Content Security Policy
let ContentSecurityPolicy = ``
if (process.env.NODE_ENV === 'production') {
ContentSecurityPolicy = `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval';
connect-src 'self' vitals.vercel-insights.com;
style-src 'self' 'unsafe-inline' *;
font-src 'self';
img-src 'self' data: *;
`;
}
/**
* Security:
* X Content Type Options
* X Frame Options
* X XSS Protection
* Security Policy
*/
const securityHeaders = () => [
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'X-XSS-Protection',
value: '1; mode=block',
},
{
key: 'Content-Security-Policy',
value: ContentSecurityPolicy.replace(/\s{2,}/g, ' ').trim(),
},
];
plugins.push(withPWA);
/** @type {import('next').NextConfig} */
const nextConfig = {
i18n: {
locales: ['en', 'es'],
defaultLocale: 'en',
localeDetection: false,
},
reactStrictMode: true,
swcMinify: true,
/*
Problem with 12.3.1 false error for property see more https://github.com/vercel/next.js/issues/39161
*/
pwa: {
register: true,
skipWaiting: true,
runtimeCaching,
buildExcludes: [/middleware-manifest.json$/],
},
// Security Headers
async headers() {
return [
{
source: '/:path*',
headers: securityHeaders(),
},
];
},
// Webpack
webpack: (config) => {
config.plugins.push(
new CircularDependencyPlugin({
exclude: /a\.js|node_modules/,
include: /src/,
failOnError: true,
allowAsyncCycles: false,
cwd: process.cwd(),
})
);
return config;
},
};
module.exports = () => plugins.reduce((acc, next) => next(acc), nextConfig);