Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
39 lines (34 loc) · 1.5 KB
/
Copy pathnext.config.ts
File metadata and controls
39 lines (34 loc) · 1.5 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
import type { NextConfig } from "next"
const isDev = process.env.NODE_ENV !== "production"
// Pages are statically rendered, so Next's inline bootstrap scripts need 'unsafe-inline'.
// Moving to nonce-based CSP would require rendering every page dynamically.
const contentSecurityPolicy = [
"default-src 'self'",
`script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ""}`,
"style-src 'self' 'unsafe-inline'",
"font-src 'self'",
"img-src 'self' data: https://avatars.githubusercontent.com",
// The landing-page check-up reads public repos straight from GitHub in the browser
"connect-src 'self' https://api.github.com",
"object-src 'none'",
"base-uri 'self'",
// Sign-in submits a form that redirects to GitHub's OAuth page
"form-action 'self' https://github.com",
"frame-ancestors 'none'",
...(isDev ? [] : ["upgrade-insecure-requests"]),
].join("; ")
const securityHeaders = [
{ key: "Content-Security-Policy", value: contentSecurityPolicy },
{ key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains; preload" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), browsing-topics=()" },
]
const nextConfig: NextConfig = {
poweredByHeader: false,
async headers() {
return [{ source: "/:path*", headers: securityHeaders }]
},
}
export default nextConfig