Repository navigation
Expand file tree
/
Copy pathnext.config.ts
More file actions
86 lines (79 loc) · 3.16 KB
/
Copy pathnext.config.ts
File metadata and controls
86 lines (79 loc) · 3.16 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
// Copyright (c) Helio Chissini de Castro, 2023. Part of the SW360 Frontend Project.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
// SPDX-License-Identifier: EPL-2.0
// License-Filename: LICENSE
import { NextConfig } from 'next'
import createNextIntlPlugin from 'next-intl/plugin'
const withNextIntl = createNextIntlPlugin()
const isDev = process.env.NODE_ENV === 'development'
const sw360ApiUrl = process.env.NEXT_PUBLIC_SW360_API_URL || ''
const csp = `
default-src 'self';
script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ''};
style-src 'self' 'unsafe-inline';
img-src 'self' data: https://secure.gravatar.com https://www.gravatar.com;
font-src 'self' data:;
connect-src 'self' https://www.gravatar.com${isDev ? ' http://localhost:*' : ''}${sw360ApiUrl ? ` ${sw360ApiUrl}` : ''};
object-src 'none';
frame-ancestors 'self';
`
.replace(/\s{2,}/g, ' ')
.trim()
const config: NextConfig = {
productionBrowserSourceMaps: true,
reactStrictMode: true,
output: 'standalone',
typescript: {
ignoreBuildErrors: false,
},
// biome-ignore-start lint: Next.js config requires this async method pattern for custom headers
async headers() {
return [
{
// Apply security headers to all routes
source: '/:path*',
headers: [
{
// HTTP Strict Transport Security (HSTS) - RFC 6797
key: 'Strict-Transport-Security',
value: 'max-age=31536000; includeSubDomains; preload',
},
{
// Prevent MIME type sniffing
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
// Disable built-in XSS protection to avoid conflicts with modern browsers
key: 'X-XSS-Protection',
value: '0',
},
{
// Control how much referrer information should be included
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin',
},
{
// Prevent clickjacking attacks
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
// Content Security Policy
key: 'Content-Security-Policy',
value: csp,
},
{
// Permissions Policy (formerly Feature-Policy)
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()',
},
],
},
]
},
// biome-ignore-end lint: Next.js config requires this async method pattern for custom headers
}
export default withNextIntl(config)