-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnext.config.js
63 lines (55 loc) · 1.66 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
require('dotenv').config({
path: `.env.${process.env.NODE_ENV}`
})
const { createSecureHeaders } = require("next-secure-headers");
const isDev = process.env.NODE_ENV !== 'production'
module.exports = {
reactStrictMode: true,
swcMinify: true,
webpack: function (config) {
config.module.rules.push({
test: /\.md$/,
use: 'markdown-loader'
})
return config
},
sassOptions: {
outputStyle: 'expanded',
indentWidth: 4,
additionalData: `
@use 'styles/vars' as *;
@use 'styles/breakpoints' as *;
@use 'styles/utilities' as utils;
@use 'styles/animations' as animations;
`
},
async headers() {
const baseString = ["'self'", "data:", "blob:", "wss:", "firebasedatabase.app", "*.firebasedatabase.app"]
// Default content security policy
const cspString = isDev
? [...baseString, "'unsafe-inline'", "'unsafe-eval'"]
: baseString
// Add additional content security policy directives
const connectSrc = [...cspString, process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN, 'identitytoolkit.googleapis.com']
const directives = {
'default-src': cspString,
'script-src': cspString,
'style-src': cspString,
'img-src': "'self' https: data:",
'font-src': cspString,
'connect-src': connectSrc,
'frame-src': cspString,
'media-src': cspString
}
return [{
source: "/(.*)",
headers: createSecureHeaders({
contentSecurityPolicy: {
directives
},
forceHTTPSRedirect: [true, { maxAge: 60 * 60 * 24 * 4, includeSubDomains: true }],
referrerPolicy: "same-origin",
})
}];
},
}, {}