-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathnext.config.js
More file actions
173 lines (166 loc) · 4.35 KB
/
next.config.js
File metadata and controls
173 lines (166 loc) · 4.35 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/** @type {import('next').NextConfig} */
const withPWA = require('next-pwa')({
dest: 'public',
register: true,
skipWaiting: true,
disable: process.env.NODE_ENV === 'development', // Disable PWA in development
runtimeCaching: [
{
// Cache Next.js static assets
urlPattern: /^\/_next\/.*/i,
handler: 'StaleWhileRevalidate',
options: { cacheName: 'next-assets' },
},
{
// Cache patient vitals API
urlPattern: /^https:\/\/.*\/api\/patient\/vitals.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'patient-vitals',
networkTimeoutSeconds: 3,
expiration: { maxEntries: 100, maxAgeSeconds: 60 * 60 }, // 1 hour
},
},
{
// Cache emergency contacts API
urlPattern: /^https:\/\/.*\/api\/patient\/emergency.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'emergency-contacts',
networkTimeoutSeconds: 3,
expiration: { maxEntries: 50, maxAgeSeconds: 24 * 60 * 60 }, // 24 hours
},
},
{
// Cache medications API
urlPattern: /^https:\/\/.*\/api\/patient\/medications.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'medications',
networkTimeoutSeconds: 3,
expiration: { maxEntries: 50, maxAgeSeconds: 24 * 60 * 60 }, // 24 hours
},
},
{
// Cache medical records API
urlPattern: /^https:\/\/.*\/api\/patient\/records.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'medical-records',
networkTimeoutSeconds: 3,
expiration: { maxEntries: 100, maxAgeSeconds: 12 * 60 * 60 }, // 12 hours
},
},
{
// Cache doctor appointments API
urlPattern: /^https:\/\/.*\/api\/appointments.*/i,
handler: 'NetworkFirst',
options: {
cacheName: 'appointments',
networkTimeoutSeconds: 5,
expiration: { maxEntries: 50, maxAgeSeconds: 6 * 60 * 60 }, // 6 hours
},
},
{
// Cache images and other resources
urlPattern: /^https?.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'external-resources',
expiration: { maxEntries: 200, maxAgeSeconds: 24 * 60 * 60 }, // 24 hours
},
},
],
});
const nextConfig = {
reactStrictMode: true,
trailingSlash: true,
images: {
unoptimized: true,
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
// Security headers
async headers() {
return [
{
// Apply security headers to all routes
source: '/(.*)',
headers: [
{
key: 'X-Frame-Options',
value: 'DENY'
},
{
key: 'X-Content-Type-Options',
value: 'nosniff'
},
{
key: 'X-XSS-Protection',
value: '1; mode=block'
},
{
key: 'Referrer-Policy',
value: 'strict-origin-when-cross-origin'
},
{
key: 'Permissions-Policy',
value: 'geolocation=(), microphone=(), camera=()'
}
]
},
{
// Additional security for API routes
source: '/api/(.*)',
headers: [
{
key: 'X-RateLimit-Limit',
value: '100'
},
{
key: 'X-RateLimit-Remaining',
value: '99'
},
{
key: 'X-RateLimit-Reset',
value: '60'
}
]
}
];
},
// Environment variable validation
onDemandEntries: {
maxInactiveAge: 25 * 1000,
pagesBufferLength: 2,
},
// Disable x-powered-by header
poweredByHeader: false,
// Compression
compress: true,
};
// Add security headers so Google Fonts can load under a strict CSP
nextConfig.headers = async () => {
return [
{
source: '/(.*)',
headers: [
{
key: 'Content-Security-Policy',
value: "default-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com data:; img-src 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; connect-src 'self' https:; manifest-src 'self';",
},
],
},
]
}
module.exports = withPWA(nextConfig);