-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
51 lines (49 loc) · 2.05 KB
/
Copy pathnext.config.ts
File metadata and controls
51 lines (49 loc) · 2.05 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
import type { NextConfig } from "next";
const nextConfig: NextConfig = {
output: 'standalone',
async headers() {
return [
{
// CORS for API routes — allow agent SDKs from any origin
source: '/api/:path*',
headers: [
{ key: 'Access-Control-Allow-Origin', value: process.env.CORS_ORIGIN || '*' },
{ key: 'Access-Control-Allow-Methods', value: 'GET, POST, PATCH, OPTIONS' },
{ key: 'Access-Control-Allow-Headers', value: 'Content-Type, X-API-Key, Authorization, Idempotency-Key, X-Dashboard-Key, X-Request-ID' },
{ key: 'Access-Control-Expose-Headers', value: 'X-Request-ID, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-Decision-Id, Retry-After' },
{ key: 'Access-Control-Max-Age', value: '86400' },
],
},
{
// Security headers for all routes
source: '/:path*',
headers: [
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-XSS-Protection', value: '1; mode=block' },
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
{ key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval'",
"style-src 'self' 'unsafe-inline' fonts.googleapis.com",
"font-src 'self' fonts.gstatic.com",
"img-src 'self' data: blob:",
"connect-src 'self'",
"frame-ancestors 'none'",
"base-uri 'self'",
"form-action 'self'",
].join('; '),
},
// HSTS — enforce HTTPS in production
...(process.env.NODE_ENV === 'production' ? [
{ key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains; preload' },
] : []),
],
},
];
},
};
export default nextConfig;