forked from Fracverse/InheritX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
75 lines (67 loc) · 2 KB
/
Copy pathnext.config.ts
File metadata and controls
75 lines (67 loc) · 2 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
import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin";
import withBundleAnalyzer from "@next/bundle-analyzer";
import withPWAInit from "@ducanh2912/next-pwa";
const withNextIntl = createNextIntlPlugin("./i18n/request.ts");
const withBundleAnalyzerConfig = withBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
});
const withPWA = withPWAInit({
dest: "public",
disable: process.env.NODE_ENV === "development",
register: true,
});
/**
* Security headers are primarily applied by middleware.ts on every request.
* The headers() config below acts as a complementary layer — it covers
* static-file responses and CDN-cached pages that bypass middleware.
*
* Issue #417 — Add Security Headers Middleware
*/
const securityHeaders = [
// Prevent MIME-type sniffing
{ key: "X-Content-Type-Options", value: "nosniff" },
// Clickjacking protection (legacy browsers; CSP frame-ancestors handles modern ones)
{ key: "X-Frame-Options", value: process.env.X_FRAME_OPTIONS ?? "DENY" },
// Legacy XSS filter
{ key: "X-XSS-Protection", value: "1; mode=block" },
// Referrer information control
{
key: "Referrer-Policy",
value: process.env.REFERRER_POLICY ?? "strict-origin-when-cross-origin",
},
// Restrict browser feature access
{
key: "Permissions-Policy",
value:
process.env.PERMISSIONS_POLICY ??
"camera=(), microphone=(), geolocation=(), payment=(), usb=(), interest-cohort=()",
},
];
const nextConfig: NextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "images.unsplash.com",
},
{
protocol: "https",
hostname: "plus.unsplash.com",
},
],
},
compiler: {
removeConsole: process.env.NODE_ENV === "production",
},
async headers() {
return [
{
// Apply to all routes
source: "/(.*)",
headers: securityHeaders,
},
];
},
};
export default withBundleAnalyzerConfig(withPWA(withNextIntl(nextConfig)));