-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext.config.ts
More file actions
67 lines (63 loc) · 2.11 KB
/
Copy pathnext.config.ts
File metadata and controls
67 lines (63 loc) · 2.11 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
import type { NextConfig } from "next";
// Next's dev overlay and HMR runtime need eval; production builds do not.
const SCRIPT_SRC =
process.env.NODE_ENV === "production"
? "script-src 'self' 'unsafe-inline'"
: "script-src 'self' 'unsafe-inline' 'unsafe-eval'";
const CSP = [
"default-src 'self'",
SCRIPT_SRC,
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob: https://image.tmdb.org",
"connect-src 'self' blob: data: https:",
"media-src 'self' blob: data: https:",
"worker-src 'self' blob:",
"font-src 'self' data:",
"frame-ancestors 'self'",
"base-uri 'self'",
"object-src 'none'",
"form-action 'self'",
].join("; ");
const nextConfig: NextConfig = {
output: "standalone",
poweredByHeader: false,
images: {
// WebP only. TMDB already serves right-sized JPEGs, so AVIF bought a few
// KB per poster in exchange for the slowest encoder in the optimizer, on a
// box that also proxies HLS segments.
formats: ["image/webp"],
deviceSizes: [640, 750, 828, 1080, 1200, 1280, 1920, 2048],
imageSizes: [92, 154, 185, 300, 342, 500, 780],
minimumCacheTTL: 60 * 60 * 24 * 30,
remotePatterns: [
{
protocol: "https",
hostname: "image.tmdb.org",
pathname: "/t/p/**",
},
],
},
headers: async () => [
{
source: "/(.*)",
headers: [
{ key: "X-Frame-Options", value: "SAMEORIGIN" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" },
{ key: "Content-Security-Policy", value: CSP },
],
},
{
source: "/api/mobile/:path*",
headers: [{ key: "Access-Control-Allow-Origin", value: "*" }],
},
// /api/hls is deliberately absent: the segment proxy is same-origin only,
// so no third-party page can drive it from a browser.
{
source: "/api/(search|resolve|resolve-vf|episodes)",
headers: [{ key: "Access-Control-Allow-Origin", value: "*" }],
},
],
};
export default nextConfig;