-
Notifications
You must be signed in to change notification settings - Fork 2
/
next.config.js
89 lines (79 loc) · 3.03 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
const {buildCspHeader} = require("@navikt/nav-dekoratoren-moduler/ssr");
const {i18n} = require("./next-i18next.config");
const appDirectives = {
"default-src": ["'self'"],
"script-src": ["'self'", "'unsafe-eval'", "https://uxsignals-frontend.uxsignals.app.iterate.no"],
"script-src-elem": ["'self'", "https://uxsignals-frontend.uxsignals.app.iterate.no"],
"style-src": ["'self'", "unsafe-inline"],
"img-src": ["'self'", "data:", "https://uxsignals-frontend.uxsignals.app.iterate.no"],
"font-src": ["'self'", "https://cdn.nav.no"],
"worker-src": ["'self'"],
"connect-src": [
"'self'",
"https://*.nav.no",
"https://*.uxsignals.com",
...(process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === "local" ? ["http://localhost:8989"] : []),
],
};
const {withSentryConfig} = require("@sentry/nextjs");
const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, configFile, stripPrefix, urlPrefix, include, ignore
org: "nav",
project: "sosialhjelp-innsyn",
// An auth token is required for uploading source maps.
// You can get an auth token from https://sentry.io/settings/account/api/auth-tokens/
// The token must have `project:releases` and `org:read` scopes for uploading source maps
authToken: process.env.SENTRY_AUTH_TOKEN,
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
};
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
async headers() {
const environment = process.env.NEXT_PUBLIC_RUNTIME_ENVIRONMENT === "prod" ? "prod" : "dev";
const cspValue = await buildCspHeader(appDirectives, {env: environment});
return [
{
source: "/:path*",
headers: [
{
key: "Content-Security-Policy",
value: cspValue,
},
],
},
];
},
output: "standalone",
assetPrefix: process.env.NODE_ENV === "production" ? process.env.NEXT_PUBLIC_ASSET_PREFIX : undefined,
reactStrictMode: true,
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
experimental: {
scrollRestoration: true,
},
eslint: {
ignoreDuringBuilds: true,
dirs: ["src"],
},
trailingSlash: true,
productionBrowserSourceMaps: true,
};
module.exports = {
compiler: {
// see https://styled-components.com/docs/tooling#babel-plugin for more info on the options.
styledComponents: {ssr: true, displayName: true},
},
...withSentryConfig(nextConfig, sentryWebpackPluginOptions),
webpack: (config) => {
// Unset client-side javascript that only works server-side
config.resolve.fallback = {fs: false, module: false, path: false};
return config;
},
i18n,
};