-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
96 lines (88 loc) · 2.59 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
// This file sets a custom webpack configuration to use your Next.js app
// with Sentry.
// https://nextjs.org/docs/api-reference/next.config.js/introduction
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
const { withSentryConfig } = require("@sentry/nextjs")
const path = require("path")
const { randomBytes } = require("crypto")
const { version, homepage } = require("./package.json")
const nonce = randomBytes(8).toString("base64")
process.env.NONCE = nonce
const ContentSecurityPolicy =
process.env.NODE_ENV === "production"
? `
default-src 'self' matomo.fabrique.social.gouv.fr;
report-uri /api/report;
report-to endpoint;
object-src 'none';
base-uri 'none';
style-src 'self' 'unsafe-inline';
img-src 'self' data: authjs.dev;
script-src 'nonce-${nonce}' 'strict-dynamic';
connect-src 'self' api.github.com matomo.fabrique.social.gouv.fr ${process.env.NEXT_PUBLIC_HASURA_URL} sentry.fabrique.social.gouv.fr;
`
: `
default-src 'self' matomo.fabrique.social.gouv.fr;
object-src 'none';
base-uri 'none';
style-src 'self' 'unsafe-inline';
img-src 'self' data: authjs.dev;
script-src 'self' 'unsafe-eval';
connect-src 'self' localhost:8080 api.github.com matomo.fabrique.social.gouv.fr sentry.fabrique.social.gouv.fr;
`
const headers = [
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Content-Security-Policy",
value: ContentSecurityPolicy.replace(/\s{2,}/g, " ").trim(),
},
{ key: "Reporting-Endpoints", value: "endpoint=/api/report" },
]
const nextConfig = {
swcMinify: true,
optimizeFonts: false,
reactStrictMode: true,
images: {
dangerouslyAllowSVG: true,
domains: ["avatars.githubusercontent.com", "secure.gravatar.com"],
contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;",
},
output: "standalone",
env: {
NEXT_PUBLIC_APP_VERSION: version,
NEXT_PUBLIC_APP_REPOSITORY_URL: homepage,
},
sassOptions: {
includePaths: [path.join(__dirname, "src", "styles")],
},
async headers() {
return [
{
source: "/:path*",
headers,
},
]
},
}
const sentryWebpackPluginOptions = {
org: "incubateur",
project: "secretariat",
url: "https://sentry.fabrique.social.gouv.fr/",
release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
}
const sentryOptions = {
widenClientFileUpload: true,
hideSourceMaps: true,
}
module.exports = withSentryConfig(
nextConfig,
sentryWebpackPluginOptions,
sentryOptions
)