-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.js
77 lines (70 loc) · 1.93 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
// 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 sentryDomain = process.env.SENTRY_DOMAIN || ""
const ContentSecurityPolicy =
process.env.NODE_ENV === "production"
? `
default-src 'self';
object-src 'none';
base-uri 'none';
style-src 'self' 'unsafe-inline';
img-src 'self' data: authjs.dev;
script-src 'nonce-${nonce}';
connect-src 'self' ${sentryDomain};
`
: `
default-src 'self';
object-src 'none';
base-uri 'none';
style-src 'self' 'unsafe-inline';
img-src 'self' data: authjs.dev;
script-src 'self' 'unsafe-inline' 'unsafe-eval';
connect-src 'self' ${sentryDomain};
`
const securityHeaders = [
{
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(),
// },
]
module.exports = {
swcMinify: true,
optimizeFonts: false,
reactStrictMode: true,
sentry: {
hideSourceMaps: true,
disableClientWebpackPlugin: true,
disableServerWebpackPlugin: true,
},
output: "standalone",
env: {
NEXT_PUBLIC_APP_VERSION: version,
NEXT_PUBLIC_APP_REPOSITORY_URL: homepage,
},
async headers() {
return [
{
source: "/:path*",
headers: securityHeaders,
},
]
},
experimental: { instrumentationHook: true },
}
module.exports = withSentryConfig(module.exports, { silent: true })