Repository navigation
Expand file tree
/
Copy pathnext.config.js
More file actions
82 lines (81 loc) · 2.74 KB
/
Copy pathnext.config.js
File metadata and controls
82 lines (81 loc) · 2.74 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
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
images: {
// Define device sizes for responsive images
deviceSizes: [180, 360, 720, 1080],
// Image formats to generate (WebP is efficient)
formats: ['image/webp'],
// Disable unoptimized mode since we're handling optimization
unoptimized: false,
// Remote image patterns for external hosts
remotePatterns: [
{
protocol: 'https',
hostname: 'coverartarchive.org',
pathname: '**',
},
{
protocol: 'https',
hostname: '*.archive.org',
pathname: '**',
}
],
},
async rewrites() {
return [
// Note: /api/musicbrainz rewrite removed to allow OAuth authentication via API route handlers
// The API route at src/app/api/musicbrainz/route.ts handles proxying with auth tokens
{
source: '/api/coverart/:path*',
destination: 'https://coverartarchive.org/:path*',
},
];
},
async headers() {
return [
{
// Apply security headers to all routes
source: '/:path*',
headers: [
{
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=(), interest-cohort=()',
},
{
key: 'Content-Security-Policy',
value: [
"default-src 'self'",
// unsafe-eval only for the dev server (hot reload); production bundles don't need it
`script-src 'self' 'unsafe-inline'${process.env.NODE_ENV === 'development' ? " 'unsafe-eval'" : ''}`,
"style-src 'self' 'unsafe-inline'", // Tailwind requires unsafe-inline
"img-src 'self' https://coverartarchive.org https://*.archive.org data: blob:",
"connect-src 'self' https://musicbrainz.org https://music.apple.com",
"font-src 'self' data:",
"object-src 'none'",
"base-uri 'self'",
"form-action 'self' https://musicbrainz.org", // Allow OAuth form submission
"frame-ancestors 'none'",
// Only over HTTPS: on plain-HTTP deployments (COOKIE_SECURE=false, e.g. a LAN server)
// the browser would upgrade every request to https and nothing would load
...(process.env.COOKIE_SECURE === 'false' ? [] : ["upgrade-insecure-requests"]),
].join('; '),
},
],
},
];
},
}
module.exports = nextConfig