SPB Git

Repository Public

next.config.ts 2.2 KB 51 lines typescript

1import type { NextConfig } from "next";23// Streams, their segments and channel logos are loaded by the browser straight from their public origins (no video4// proxy), so media, images and XHR are open to any origin; everything executable stays same-origin.5const csp = [6  "default-src 'self'",7  `script-src 'self' 'unsafe-inline'${process.env.NODE_ENV === "production" ? "" : " 'unsafe-eval'"}`,8  "style-src 'self' 'unsafe-inline'",9  "img-src 'self' data: blob: https: http:",10  "media-src 'self' blob: https: http:",11  "connect-src 'self' https: http:",12  "worker-src 'self' blob:",13  // Official embedded players only (ONF / NFB, ARTE).14  "frame-src https://www.onf.ca https://www.nfb.ca https://www.arte.tv",15  "font-src 'self'",16  "frame-ancestors 'none'",17  "base-uri 'self'",18  "form-action 'self'",19  "object-src 'none'",20].join("; ");2122const config: NextConfig = {23  poweredByHeader: false,24  serverExternalPackages: ["undici", "@simplewebauthn/server"],25  // A Jellyfin server on this machine can be published under /jellyfin of this site: it gets HTTPS and sits behind the26  // SP TV session check (src/proxy.ts runs before this rewrite), so it is never reachable without being signed in here.27  async rewrites() {28    const target = process.env.JELLYFIN_PROXY?.replace(/\/+$/, "");29    return target ? [{ source: "/jellyfin/:path*", destination: `${target}/jellyfin/:path*` }] : [];30  },31  async headers() {32    return [33      {34        source: "/:path*",35        headers: [36          { key: "Content-Security-Policy", value: csp },37          { key: "X-Content-Type-Options", value: "nosniff" },38          // Never tell a stream origin which page is playing it.39          { key: "Referrer-Policy", value: "same-origin" },40          { key: "X-Frame-Options", value: "DENY" },41          { key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=(), interest-cohort=()" },42          { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },43          { key: "X-Robots-Tag", value: "noindex, nofollow" },44        ],45      },46      { source: "/sw.js", headers: [{ key: "Cache-Control", value: "no-cache" }, { key: "Service-Worker-Allowed", value: "/" }] },47    ];48  },49};50export default config;51
Files main
Menu

Theme