-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathnext.config.mjs
104 lines (98 loc) · 2.84 KB
/
next.config.mjs
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
import { withSentryConfig } from "@sentry/nextjs";
import MappingReplacement from "./redirects.json" assert { type: "json" };
const ContentSecurityPolicy = `
img-src 'self' https://travail-emploi.gouv.fr https://www.service-public.fr https://cdtn-prod-public.s3.gra.io.cloud.ovh.net https://matomo.fabrique.social.gouv.fr;
script-src 'self' https://mon-entreprise.urssaf.fr https://matomo.fabrique.social.gouv.fr ${
process.env.NEXT_PUBLIC_APP_ENV !== "production" ? "'unsafe-eval'" : ""
};
frame-src 'self' https://mon-entreprise.urssaf.fr https://matomo.fabrique.social.gouv.fr *.dailymotion.com;
connect-src 'self' https://geo.api.gouv.fr https://sentry.fabrique.social.gouv.fr https://matomo.fabrique.social.gouv.fr;
worker-src 'self' blob:;
`;
const sentryConfig = {
org: process.env.NEXT_PUBLIC_SENTRY_ORG,
project: process.env.NEXT_PUBLIC_SENTRY_PROJECT,
sentryUrl: process.env.NEXT_PUBLIC_SENTRY_URL,
authToken: process.env.SENTRY_AUTH_TOKEN,
release: {
name: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
setCommits: process.env.NEXT_PUBLIC_COMMIT
? {
repo: "SocialGouv/code-du-travail-numerique",
commit: process.env.NEXT_PUBLIC_COMMIT,
}
: { auto: true },
},
hideSourceMaps: true,
widenClientFileUpload: true,
};
const nextConfig = {
poweredByHeader: false,
compiler: {
reactRemoveProperties:
process.env.NEXT_PUBLIC_APP_ENV === "production"
? { properties: ["data-testid"] }
: false,
styledComponents: true,
},
eslint: {
ignoreDuringBuilds: true,
},
staticPageGenerationTimeout: 60 * 5, // 5 minutes
experimental: {
instrumentationHook: true,
},
webpack: (config) => {
config.module.rules.push({
test: /\.woff2$/,
type: "asset/resource",
});
return config;
},
transpilePackages: ["@codegouvfr/react-dsfr"],
};
const moduleExports = {
...nextConfig,
async headers() {
let headers = [
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Content-Security-Policy",
value: ContentSecurityPolicy.replace(/\n/g, " ").trim(),
},
];
if (process.env.NEXT_PUBLIC_IS_PRODUCTION_DEPLOYMENT) {
headers.push({
key: "X-Robots-Tag",
value: "all",
});
} else {
headers.push({
key: "X-Robots-Tag",
value: "noindex, nofollow, nosnippet",
});
}
return [
{
source: "/:path*",
headers,
},
{
source: "/((?!widgets|widget.html$).*)", // all paths except those starting with "/widgets" or /widget.html used in widgets
headers: [
{
key: "X-Frame-Options",
value: "DENY",
},
],
},
];
},
async redirects() {
return MappingReplacement;
},
};
export default withSentryConfig(moduleExports, sentryConfig);