Files
threadcount-community/next.config.ts
T
ThreadCount 96d5c10537 ThreadCount Community edition
Uniform stock management for healthcare linen rooms: the coordinator app, the phone counter and the staff app, for your own server. Built from 49da3a4 on 2026-09-13. Licensed under the Functional Source License (FSL-1.1-ALv2).
2026-09-13 11:38:24 +10:00

52 lines
2.5 KiB
TypeScript

import type { NextConfig } from "next";
import { HOSTED_TELEMETRY_HOSTS } from "./lib/hosted-defaults";
// The telemetry hosts the policy admits: the hosted service's own, or none in the Community
// edition (whose lib/hosted-defaults.ts is blank), plus whatever an operator set explicitly.
const telemetry = [...HOSTED_TELEMETRY_HOSTS, ...[process.env.NEXT_PUBLIC_UMAMI_SRC, process.env.NEXT_PUBLIC_GLITCHTIP_DSN].map((u) => { try { return u ? new URL(u).origin : ""; } catch { return ""; } })].filter(Boolean);
const scriptHosts = ["https://challenges.cloudflare.com", ...telemetry].join(" ");
const connectHosts = ["'self'", ...telemetry].join(" ");
// Security headers. Inline styles/scripts are part of how Next hydrates and how the print windows are
// built, so CSP allows 'unsafe-inline' for those while still pinning every origin to self.
const csp = [
"default-src 'self'",
// Cloudflare Insights is not used and never was — the entries were permissive leftovers.
`script-src 'self' 'unsafe-inline' ${scriptHosts}`,
"frame-src https://challenges.cloudflare.com",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' data: blob:",
"media-src 'self' blob:",
"font-src 'self' data:",
`connect-src ${connectHosts}`,
"worker-src 'self' blob:",
"frame-ancestors 'none'",
"base-uri 'self'",
"form-action 'self'",
"object-src 'none'",
].join("; ");
const headers = [
{ key: "Content-Security-Policy", value: csp },
{ key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" },
{ key: "X-Content-Type-Options", value: "nosniff" },
{ key: "X-Frame-Options", value: "DENY" },
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
{ key: "Permissions-Policy", value: "camera=(self), microphone=(), geolocation=(), payment=(), usb=()" },
];
const nextConfig: NextConfig = {
poweredByHeader: false,
// The Docker image (Community edition) runs Next's standalone server; the hosted box runs
// `next start` from the full build, which standalone output would warn about. Opt in per build.
...(process.env.NEXT_OUTPUT === "standalone" ? { output: "standalone" as const } : {}),
// Browser source maps are built so a deploy can upload them to the error tracker against the
// release, then delete them from .next/static before the site restarts — they are never served. Symbolicated client stacks in GlitchTip without pulling an SDK into the bundle.
productionBrowserSourceMaps: true,
async headers() {
return [{ source: "/(.*)", headers }];
},
};
export default nextConfig;