45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import type { NextConfig } from "next";
|
|
|
|
/**
|
|
* Baseline security headers for every response. The app is served behind an
|
|
* external reverse proxy, so TLS/HSTS is the proxy's job; these are the
|
|
* application-level defaults that should never depend on the proxy.
|
|
*/
|
|
const nextConfig: NextConfig = {
|
|
// sharp ships a native binary; let Node load it at runtime instead of trying
|
|
// to bundle it into the server build.
|
|
serverExternalPackages: ["sharp"],
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/:path*",
|
|
headers: [
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{
|
|
key: "Permissions-Policy",
|
|
value: "camera=(), microphone=(), geolocation=()",
|
|
},
|
|
],
|
|
},
|
|
// API routes skip middleware so uploads are not buffered and truncated
|
|
// at 10 MB; keep the clickjacking protection here instead.
|
|
{
|
|
source: "/api/:path*",
|
|
headers: [{ key: "X-Frame-Options", value: "DENY" }],
|
|
},
|
|
// The embed player is intentionally frameable so a watch link can be
|
|
// dropped into a website, LMS, or social platform. Every other page is
|
|
// protected by middleware with X-Frame-Options: DENY.
|
|
{
|
|
source: "/embed/:path*",
|
|
headers: [
|
|
{ key: "Content-Security-Policy", value: "frame-ancestors *" },
|
|
],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|