-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnext.config.js
184 lines (180 loc) · 5.28 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/**
* @file
* This is the configuration file for Next.js.
*
* See https://nextjs.org/docs/api-reference/next.config.js/introduction
*
* We set distDir, such that the build folder is located next to the storybook build
*/
// {
// source: "/_next/image:slug*",
// headers: [
// {
// key: "Cache-Control",
// value: "public, s-maxage=600",
// },
// ],
// },
// {
// source: "/img:slug*",
// headers: [
// {
// key: "Cache-Control",
// value: "public, s-maxage=600",
// },
// ],
// },
const headers = [
{
key: "Content-Security-Policy", // prevents XSS attacks. Allow only whitelisted sources
value:
"default-src 'self'; script-src 'self' *.dbc.dk https://consent.cookiebot.eu https://consentcdn.cookiebot.eu 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' https://moreinfo.addi.dk img.sct.eu1.usercentrics.eu data: *.dbc.dk; connect-src 'self' https://consentcdn.cookiebot.eu https://consent.cookiebot.eu https://stats.dbc.dk *.dbc.dk; frame-src 'self' *.dbc.dk; font-src 'self' data:; ",
},
{
key: "X-Content-Type-Options",// prevents the browser from guessing the content type. This will prevent MIME sniffing
value: "nosniff",
},
{
key: "X-Frame-Options",// prevents the page from being rendered in an iframe
value: "SAMEORIGIN",
},
{
key: "Strict-Transport-Security", // forces the browser to use https
value: "max-age=31536000; includeSubDomains",
},
{
key: "Referrer-Policy", // will include full url in referrer for requests from same origin. But only the origin(bibliotek.dk) for requests from other origins
value: "origin-when-cross-origin",
},
];
module.exports = {
distDir: "dist/next",
headers: async () => {
return [
{
source: "/(.*)", //all pages
headers,
},
{
source: "/", //frontpage. For some reason frontpage is not included in the above path
headers,
},
];
},
i18n: {
locales: ["da", "en"],
defaultLocale: "da",
localeDetection: false,
},
images: {
domains: [
"forfatterweb.dk",
"bibdk-backend-www-master.febib-prod.svc.cloud.dbc.dk",
"bibdk-backend-www-master.febib-staging.svc.cloud.dbc.dk",
"bibdk-backend-www-master.frontend-staging.svc.cloud.dbc.dk",
],
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384, 640, 1400],
},
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: ["@svgr/webpack"],
});
return config;
},
async rewrites() {
return [
{
source: "/robots.txt",
destination: "/api/robots",
},
];
},
async redirects() {
return [
{
source: "/hj%C3%A6lp",
destination: "/hjaelp",
permanent: true,
},
{
source: "/help",
destination: "/hjaelp",
permanent: true,
},
{
source: "/inspiration/b%C3%B8ger",
destination: "/inspiration/boeger",
permanent: true,
},
{
source: "/inspiration/bøger",
destination: "/inspiration/boeger",
permanent: true,
},
{
source: "/was",
destination: "https://www.was.digst.dk/beta-bibliotek-dk",
permanent: false,
},
{
source: "/work/((?!work-of)):workId",
destination: "/materiale/titel_skaber/work-of%3A:workId",
permanent: true,
},
{
source: "/work/work-of:workId",
destination: "/materiale/titel_skaber/work-of:workId",
permanent: true,
},
{
source: "/work/pid/:pid",
destination: "/linkme.php/?rec.id=:pid",
permanent: true,
},
];
},
experimental: {
scrollRestoration: true,
},
serverRuntimeConfig: {
// Will only be available on the server side
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
jwtSecret: process.env.NEXTAUTH_SECRET,
disableDrupalTranslate: process.env.DISABLE_DRUPAL_TRANSLATE || false,
maxError500Count: process.env.MAX_ERROR_COUNT || 2,
allowRobots: process.env.ALLOW_ROBOTS === "true" ? true : false,
},
publicRuntimeConfig: {
cookiebot: {
id: process.env.COOKIEBOT_ID || "0945225b-6b16-4166-82dd-ea5947b897b3",
mode: process.env.COOKIEBOT_MODE || "auto",
},
elbaDryRun:
typeof process.env.ELBA_DRY_RUN === "undefined"
? true
: process.env.ELBA_DRY_RUN,
// Set to false in production. When set to true, the session id is set to "test", when collecting data.
// This allow AI to remove entries with session_id=test
useFixedSessionId:
typeof process.env.USE_FIXED_SESSION_ID === "undefined" ||
process.env.USE_FIXED_SESSION_ID !== "false" ||
!process.env.USE_FIXED_SESSION_ID,
fbi_api: {
url:
process.env.NEXT_PUBLIC_FBI_API_URL ||
"https://fbi-api-staging.k8s.dbc.dk/bibdk21/graphql",
timeout: process.env.API_TIMEOUT_MS || 150,
},
fbi_api_simplesearch: {
url:
process.env.NEXT_PUBLIC_FBI_API_SIMPLESEARCH_URL ||
"https://fbi-api-staging.k8s.dbc.dk/SimpleSearch/graphql",
timeout: process.env.API_TIMEOUT_MS || 150,
},
app: {
url: process.env.NEXTAUTH_URL,
},
},
};