Files
periscope/periscope/dependency/frontend/next.config.ts
T
michele c362ef8a56 Split native Periscope (periscope/src) from inherited PinScope (periscope/dependency).
Keep validate.py and the finding engine as-is. AGPL LICENSE stays at the repo root.
Docker overlays dependency then src. Do not delete the inherited tree.
2026-09-20 14:31:42 +02:00

70 lines
2.1 KiB
TypeScript

import type { NextConfig } from "next";
import {
CSP_CONNECT_HOSTS,
CSP_FRAME_HOSTS,
CSP_SCRIPT_HOSTS,
} from "./src/lib/csp-hosts";
const extra = (hosts: string[]) => (hosts.length ? ` ${hosts.join(" ")}` : "");
function apiOrigin(): string[] {
const raw = process.env.NEXT_PUBLIC_API_URL;
if (!raw) return [];
try {
return [new URL(raw).origin];
} catch {
return [];
}
}
const connectHosts = [...CSP_CONNECT_HOSTS, ...apiOrigin()];
const nextConfig: NextConfig = {
allowedDevOrigins: ["127.0.0.1", "localhost"],
serverExternalPackages: ["pdfjs-dist"],
turbopack: {
resolveAlias: {
canvas: { browser: "" },
},
},
async redirects() {
return [
{ source: "/login", destination: "/sign-in", permanent: false },
{ source: "/register", destination: "/sign-up", permanent: false },
];
},
async headers() {
return [
{
source: "/(.*)",
headers: [
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{
key: "Strict-Transport-Security",
value: "max-age=31536000; includeSubDomains",
},
{
key: "Content-Security-Policy",
value: [
"default-src 'self'",
"script-src 'self' 'unsafe-inline' 'unsafe-eval' https://unpkg.com https://vercel.live" +
extra(CSP_SCRIPT_HOSTS),
"style-src 'self' 'unsafe-inline' https://vercel.live https://fonts.googleapis.com",
"img-src 'self' data: https: blob:",
"font-src 'self' data: https://vercel.live https://assets.vercel.com https://fonts.gstatic.com",
"connect-src 'self' blob: https://storage.googleapis.com https://vercel.live wss://ws-us3.pusher.com" +
extra(connectHosts),
"frame-src 'self' https://vercel.live" + extra(CSP_FRAME_HOSTS),
"worker-src 'self' blob:",
].join("; "),
},
],
},
];
},
};
export default nextConfig;