This repository was archived by the owner on Oct 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathnext.headers.js
More file actions
130 lines (124 loc) · 8.17 KB
/
next.headers.js
File metadata and controls
130 lines (124 loc) · 8.17 KB
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
/**
* Note: Headers specified here will only work in (npm run dev) or (npm start)
*
* Since verify.gov.sg is deployed onto AWS CloudFront, production headers are overwritten/specified separately
*/
const prodCspValue = [
"frame-ancestors 'none'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.wogaa.sg https://*.dcube.cloud/ https://assets.adobedtm.com/ https://www.googletagmanager.com https://www.google-analytics.com https://ssl.google-analytics.com",
"object-src 'self'",
"style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/css/sgds.css https://fonts.googleapis.com/ https://assets.dcube.cloud/fonts/ https://assets.wogaa.sg/",
"default-src 'self' https://*.dcube.cloud/ https://*.demdex.net/ https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.wogaa.sg",
"base-uri 'self'",
"form-action 'self'",
"img-src 'self' https://wogadobeanalytics.sc.omtrdc.net/ https://cm.everesttech.net/ https://dpm.demdex.net/ www.googletagmanager.com https://www.google-analytics.com",
"font-src 'self' https://fonts.gstatic.com/s/ https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/ data: https://assets.dcube.cloud/fonts/ data: https://assets.wogaa.sg/fonts/",
"manifest-src 'self'",
"connect-src https://*.gov.sg/ https://dns.google/ https://mainnet.infura.io/v3/ https://sepolia.infura.io/v3/ https://dpm.demdex.net/ https://*.dcube.cloud/ https://*.wogaa.sg https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.notarise.io https://*.openattestation.com https://www.google-analytics.com",
"frame-src https://*.openattestation.com https://*.gov.sg",
];
const prodVerifyCspValue = [
"frame-ancestors 'none'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://assets.adobedtm.com/ https://www.googletagmanager.com https://www.google-analytics.com https://ssl.google-analytics.com blob: https://*.wogaa.sg",
"object-src 'self'",
"style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/css/sgds.css https://fonts.googleapis.com/ https://assets.dcube.cloud/fonts/ https://assets.wogaa.sg/",
"default-src 'self' https://*.demdex.net/ https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.wogaa.sg",
"base-uri 'self'",
"form-action 'self'",
"img-src 'self' https://wogadobeanalytics.sc.omtrdc.net/ https://cm.everesttech.net/ https://dpm.demdex.net/ www.googletagmanager.com https://www.google-analytics.com",
"font-src 'self' https://fonts.gstatic.com/s/ https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/ data: https://assets.dcube.cloud/fonts/ data: https://assets.wogaa.sg/fonts/",
"manifest-src 'self'",
"connect-src https://*.gov.sg/ https://dns.google/ https://mainnet.infura.io/v3/ https://sepolia.infura.io/v3/ https://dpm.demdex.net/ https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.notarise.io https://*.openattestation.com https://www.google-analytics.com https://*.wogaa.sg",
"frame-src https://*.openattestation.com https://*.gov.sg",
];
const nonProdCspValue = [
"frame-ancestors 'none'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.wogaa.sg https://*.dcube.cloud/ https://assets.adobedtm.com/ https://www.googletagmanager.com https://www.google-analytics.com https://ssl.google-analytics.com",
"object-src 'self'",
"style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/css/sgds.css https://fonts.googleapis.com/ https://assets.dcube.cloud/fonts/ https://assets.wogaa.sg/",
"default-src 'self' https://*.dcube.cloud/ https://*.demdex.net/ https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.wogaa.sg",
"base-uri 'self'",
"form-action 'self'",
"img-src 'self' https://wogadobeanalytics.sc.omtrdc.net/ https://cm.everesttech.net/ https://dpm.demdex.net/ www.googletagmanager.com https://www.google-analytics.com",
"font-src 'self' https://fonts.gstatic.com/s/ https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/ data: https://assets.dcube.cloud/fonts/ data: https://assets.wogaa.sg/fonts/",
"manifest-src 'self'",
"connect-src https://gist.githubusercontent.com https://*.gov.sg/ https://dns.google/ https://mainnet.infura.io/v3/ https://sepolia.infura.io/v3/ https://dpm.demdex.net/ https://*.dcube.cloud/ https://*.wogaa.sg https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.openattestation.com https://www.google-analytics.com",
"frame-src https://*.openattestation.com https://*.gov.sg",
];
const nonProdVerifyCspValue = [
"frame-ancestors 'none'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://assets.adobedtm.com/ https://www.googletagmanager.com https://www.google-analytics.com https://ssl.google-analytics.com blob: https://*.dcube.cloud",
"object-src 'self'",
"style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/css/sgds.css https://fonts.googleapis.com/ https://assets.dcube.cloud/fonts/ https://assets.wogaa.sg/",
"default-src 'self' https://*.demdex.net/ https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.dcube.cloud/",
"base-uri 'self'",
"form-action 'self'",
"img-src 'self' https://wogadobeanalytics.sc.omtrdc.net/ https://cm.everesttech.net/ https://dpm.demdex.net/ www.googletagmanager.com https://www.google-analytics.com",
"font-src 'self' https://fonts.gstatic.com/s/ https://cdnjs.cloudflare.com/ajax/libs/font-awesome/ https://unpkg.com/sgds-govtech@1.3.14/ data: https://assets.dcube.cloud/fonts/ data: https://assets.wogaa.sg/fonts/",
"manifest-src 'self'",
"connect-src https://gist.githubusercontent.com https://*.gov.sg/ https://dns.google/ https://mainnet.infura.io/v3/ https://sepolia.infura.io/v3/ https://dpm.demdex.net/ https://cm.everesttech.net/ https://wogadobeanalytics.sc.omtrdc.net/ https://*.openattestation.com https://*.notarise.io https://www.google-analytics.com https://*.dcube.cloud",
"frame-src https://*.openattestation.com https://*.gov.sg",
];
/** @type {import('next').NextConfig["headers"]} */
const generateHeaders = async () => {
if (process.env.CONTEXT === "production") {
return [
{
source: "/:path*",
headers: [
{
key: "Content-Security-Policy",
value: prodCspValue.join("; "),
},
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-XSS-Protection", value: "1; mode=block" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
],
},
{
source: "/verify",
headers: [
{
key: "Content-Security-Policy",
value: prodVerifyCspValue.join("; "),
},
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-XSS-Protection", value: "1; mode=block" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
],
},
];
} else if (["deploy-preview", "branch-deploy", "staging"].includes(process.env.CONTEXT)) {
return [
{
source: "/:path*",
headers: [
{
key: "Content-Security-Policy",
value: nonProdCspValue.join("; "),
},
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-XSS-Protection", value: "1; mode=block" },
{ key: "X-Content-Type-Options", value: "nosniff" },
],
},
{
source: "/verify",
headers: [
{
key: "Content-Security-Policy",
value: nonProdVerifyCspValue.join("; "),
},
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-XSS-Protection", value: "1; mode=block" },
{ key: "X-Content-Type-Options", value: "nosniff" },
],
},
];
} else {
return [];
}
};
module.exports = { generateHeaders };