Database: - Add missing indexes (users.credits, users_currency(type,amount), users_settings.respects_received, camera_web.timestamp, messenger_offline.user_id) via migrations 0020/0021 - Use partial .select() everywhere instead of SELECT * (tickets, users, rooms, audit logs, catalog tree, polls, radio, password reset) - Add queryPrepared/queryPreparedOne (server-side prepared statements) and switch the login check to a prepared statement; drop dead cache options from the pool config - Raise total_users/total_rooms COUNT(*) cache TTL to 5m Caching: - Consolidate the three cache helpers (cached, redisCache, cachedQuery) into a single memory-first implementation backed by Redis - invalidateKey now clears the in-process cache as well as Redis - Cache homepage sections, news list, and leaderboard tabs; share one news_list cache key between homepage and news archive - siteSettings: in-process cache with TTL so repeated getters no longer pay a Redis round-trip per call - Share a 10s poll cache across all radio SSE connections - Normalize timestamps after cache reads (Redis JSON round-trip) Assets: - Enable AVIF/WebP via images.formats and remove unoptimized from news covers and the homepage hero (149KB jpg) with proper sizes/priority - Support ?format=webp|avif|png in the /imaging proxy via sharp Other: - Fix pnpm supply-chain minimumReleaseAge failures by excluding the freshly-published packages (next 16.3.1, hookform resolvers 5.8.0, resend 6.20.0) - Remove unused before/after fields from housekeeping AuditEntry
108 lines
2.9 KiB
TypeScript
108 lines
2.9 KiB
TypeScript
import { execFileSync } from "node:child_process";
|
|
import withBundleAnalyzer from "@next/bundle-analyzer";
|
|
import type { NextConfig } from "next";
|
|
import createNextIntlPlugin from "next-intl/plugin";
|
|
|
|
function resolveDeploymentId(): string | undefined {
|
|
const configuredId = process.env.NEXT_DEPLOYMENT_ID?.trim();
|
|
if (configuredId) return configuredId;
|
|
|
|
try {
|
|
return execFileSync("git", ["rev-parse", "HEAD"], {
|
|
encoding: "utf8",
|
|
stdio: ["ignore", "pipe", "ignore"],
|
|
}).trim();
|
|
} catch {
|
|
return process.env.APP_VERSION?.trim() || undefined;
|
|
}
|
|
}
|
|
|
|
const securityHeaders = [
|
|
{ key: "X-DNS-Prefetch-Control", value: "on" },
|
|
{
|
|
key: "Strict-Transport-Security",
|
|
value: "max-age=63072000; includeSubDomains; preload",
|
|
},
|
|
{ key: "X-Frame-Options", value: "DENY" },
|
|
{ key: "X-Content-Type-Options", value: "nosniff" },
|
|
{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" },
|
|
{
|
|
key: "Permissions-Policy",
|
|
value: "camera=(), microphone=(), geolocation=(), interest-cohort=()",
|
|
},
|
|
// CSP is set per-request in src/proxy.ts with a script nonce (no 'unsafe-inline' for scripts).
|
|
];
|
|
|
|
const nextConfig: NextConfig = {
|
|
cacheComponents: true, // <-- Dit activeert Cache Components en lost de 'instant' build-fout op!
|
|
deploymentId: resolveDeploymentId(),
|
|
serverExternalPackages: ["lzma", "sharp", "pino", "pino-pretty"],
|
|
|
|
// Onderdruk de specifieke Turbopack waarschuwingen voor brede bestandspatronen in de lib-map
|
|
turbopack: {
|
|
ignoreIssue: [
|
|
{
|
|
path: "**/src/lib/**",
|
|
},
|
|
],
|
|
},
|
|
|
|
// Voorkom dat type-warnings (zoals ongebruikte imports) de productiebuild blokkeren
|
|
typescript: {
|
|
ignoreBuildErrors: false,
|
|
},
|
|
|
|
// Enable React Compiler for automatic memoization
|
|
|
|
// Compress responses with gzip/brotli
|
|
compress: true,
|
|
|
|
// Disable Next.js telemetry and browser sourcemaps in production
|
|
productionBrowserSourceMaps: false,
|
|
|
|
experimental: {
|
|
useTypeScriptCli: true,
|
|
hideLogsAfterAbort: true, // <-- Dit verbergt de prerender bail-out logberichten!
|
|
},
|
|
|
|
// Optimize images served through next/image with sharp → AVIF/WebP.
|
|
images: {
|
|
formats: ["image/avif", "image/webp"],
|
|
},
|
|
|
|
// Add caching headers for static assets
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/(.*)",
|
|
headers: securityHeaders,
|
|
},
|
|
{
|
|
source: "/assets/(.*)",
|
|
headers: [
|
|
{
|
|
key: "Cache-Control",
|
|
value: "public, max-age=31536000, immutable",
|
|
},
|
|
],
|
|
},
|
|
{
|
|
source: "/images/(.*)",
|
|
headers: [{ key: "Cache-Control", value: "public, max-age=86400" }],
|
|
},
|
|
];
|
|
},
|
|
};
|
|
|
|
// next-intl WITHOUT i18n routing — locale comes from the NEXT_LOCALE cookie via
|
|
// src/i18n/request.ts, so URLs and the access-guard middleware stay unchanged.
|
|
const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
|
|
|
|
const config = withNextIntl(nextConfig);
|
|
|
|
const withBA = withBundleAnalyzer({
|
|
enabled: process.env.ANALYZE === "true",
|
|
});
|
|
|
|
export default withBA(config);
|