-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnext.config.js
111 lines (100 loc) · 2.39 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
99
100
101
102
103
104
105
106
107
108
109
110
111
/** @type {import('next').NextConfig} */
const nextTranslate = require("next-translate-plugin");
const baseHeaders = [
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
},
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Referrer-Policy",
value: "origin-when-cross-origin",
},
{
key: "Permissions-Policy",
value: "camera=(), geolocation=(), microphone=()",
},
{
key: "Access-Control-Allow-Origin",
value:
"https://www.dataportal.se https://webbanalys.digg.se https://cdn.screen9.com",
},
];
const csp = [
{
key: "Content-Security-Policy",
value: `frame-ancestors 'none';`,
},
];
const nextConfig = nextTranslate({
webpack: (config) => {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
os: false,
https: false,
http: false,
zlib: false,
events: false,
net: false,
dgram: false,
tls: false,
};
// Grab the existing rule that handles SVG imports
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.(".svg"),
);
config.module.rules.push(
// Reapply the existing rule, but only for svg imports ending in ?url
{
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
},
// Convert all other *.svg imports to React components
{
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
use: ["@svgr/webpack"],
},
);
return config;
},
productionBrowserSourceMaps: true,
env: {
REVALIDATE_INTERVAL: process.env.REVALIDATE_INTERVAL,
},
staticPageGenerationTimeout: 240,
images: {
domains: [process.env.IMAGE_DOMAIN || "localhost", "bcdn.screen9.com"],
deviceSizes: [640, 1080, 1200, 1920],
imageSizes: [128, 384],
dangerouslyAllowSVG: true,
minimumCacheTTL: 604800,
},
async headers() {
return [
{
source: "/(.*)",
headers: [...baseHeaders, ...csp],
},
{
source: "/",
headers: [...baseHeaders, ...csp],
},
];
},
});
module.exports = nextConfig;