This repository was archived by the owner on Mar 18, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
70 lines (64 loc) · 1.69 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
const { buildCspHeader } = require("@navikt/nav-dekoratoren-moduler/ssr");
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});
// Direktiver appen din benytter
const myAppDirectives = {
"script-src-elem": ["'self'", "https://widget.uxsignals.com"],
"script-src": ["'self'", "https://widget.uxsignals.com"],
"style-src": ["unsafe-inline"],
"img-src": ["'self'", "data:", "https://widget.uxsignals.com"],
"connect-src": [
"'self'",
"rt6o382n.apicdn.sanity.io",
"rt6o382n.api.sanity.io",
"https://api.uxsignals.com",
"https://widget.uxsignals.com",
],
"worker-src": ["'self'"],
"frame-src": ["*.nav.no"],
};
const supportedLocales = ["nb"];
const config = {
reactStrictMode: true,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
i18n: {
locales: supportedLocales,
defaultLocale: "nb",
},
assetPrefix: process.env.ASSET_PREFIX,
experimental: {
largePageDataBytes: 256 * 1000, // Økt fra 128KB til 256K
},
output: "standalone",
swcMinify: true,
async headers() {
const env = process.env.NEXT_PUBLIC_LOCALHOST !== "true" ? "prod" : "dev";
const csp = await buildCspHeader(myAppDirectives, { env });
return [
{
source: "/:path*",
headers: [
{
key: "Content-Security-Policy",
value: csp,
},
],
},
];
},
webpack: (config, { dev }) => {
if (dev) {
config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
};
}
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
return config;
},
};
module.exports = withBundleAnalyzer(config);